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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jeff King <peff@xxxxxxxx> writes:

> 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).

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.

> 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".
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]