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]

 



On Wed, Jan 13, 2016 at 07:03:08PM -0800, Junio C Hamano wrote:

> The program by default works on LF terminated lines, with an option
> to use NUL terminated records.  Instead of using line_termination
> that happens to take LF or NUL to call strbuf_getline(), switch
> between strbuf_getline_{lf,nul} based on the value of '-z' option.
> 
> Note that this still leaves the option open to use NUL-terminated
> input mixed with LF-terminated output (and vice versa), and even
> HT-terminated output is still left as a possibility, because this
> series is only interested in tightening the overly broad interface
> on the input side.

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.

IOW, could this OPT_CALLBACK for 'z' be simplified to a simple OPT_BOOL,
or am I missing some case?

>  #define CHECKOUT_ALL 4
>  static int line_termination = '\n';
> +static strbuf_getline_fn getline_fn = strbuf_getline_lf;

This "line_termination" can become a boolean "1" now, right?

> @@ -144,10 +145,13 @@ static int option_parse_u(const struct option *opt,
>  static int option_parse_z(const struct option *opt,
>  			  const char *arg, int unset)
>  {
> -	if (unset)
> +	if (unset) {
>  		line_termination = '\n';
> -	else
> +		getline_fn = strbuf_getline_lf;
> +	} else {
>  		line_termination = 0;
> +		getline_fn = strbuf_getline_nul;
> +	}

Ditto here (though as before, I think I prefer it as the inverse bool:
did somebody turn on "-z").

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?

-Peff
--
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]