Thread (2 messages) flat view 2 messages, 2 authors, 2016-06-15

Re: [PREVIEW v3 8/9] checkout-index: there are only two line terminators

From: Jeff King <hidden>
Date: 2016-06-15 23:07:45

On Thu, Jan 14, 2016 at 09:13:54AM -0800, Junio C Hamano wrote:
Jeff King [off-list ref] writes:
quoted
I see that we switch the line termination on the fly in option_parse_z.
But I'm having trouble seeing how we could actually have mixed inputs.
We don't actually look at the line-terminator until after all of the
options are parsed.
I do not think we are aiming for mixed inputs.  What I meant by
"mixed" in my description was a possible future option to allow
input and output using different line termination (e.g. via "-Z"
you would control output line termination, while "-z" only affects
the input line termination).
Ah, I see.
After this step, there is still one call that is more natural to
have line_termination that is either '\0' or '\n' and that is on the
output side, which calls write_name_quoted_relative() to report the
names of the temporary files that received the file contents to the
standard output.

Of course there is nothing wrong to do

        write_name_quoted_relative(name, prefix, stdout,
				   nul_term_lines ? '\0' : '\n');

though.

And I tend to think that it might even be a good idea to do so.  If
somebody in the future really wants to introduce '-Z', then they can
add a separate "output_line_termination" variable back (and it would
likely be set to '\0' or '\n' via "-z" when "-Z" is not given), but
until then, I agree that a simple bool for "-z" would be better.
Yeah, I agree with all of that.
quoted
I'm also not sure how "unset" would trigger here. If we have a long
option, we can use "--no-foo". But there isn't a long option for "-z".
Is there a way to negate short options?
I do not think there is.  It merely future-proofs against those who
try to add "--nul" as a longer synonym.  They would complain after
they add "--nul" in builtin_checkout_index_options[] as a synonym if
they see "--no-nul" does not negate the effect of an earlier "-z".
Makes sense. Better still if we can turn it into OPT_BOOL, though, and
then it would Just Work. :)

-Peff
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help