Re: [PREVIEW v3 7/9] update-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:07PM -0800, Junio C Hamano wrote:

> -static void read_index_info(int line_termination)
> +static void read_index_info(int nul_term_line)
>  {
>  	struct strbuf buf = STRBUF_INIT;
>  	struct strbuf uq = STRBUF_INIT;
> +	strbuf_getline_fn getline_fn;
>  
> -	while (strbuf_getline(&buf, stdin, line_termination) != EOF) {
> +	getline_fn = nul_term_line ? strbuf_getline_nul : strbuf_getline_lf;
> +	while (getline_fn(&buf, stdin) != EOF) {
>  		char *ptr, *tab;
>  		char *path_name;
>  		unsigned char sha1[20];
> @@ -522,7 +524,7 @@ static void read_index_info(int line_termination)
>  			goto bad_line;
>  
>  		path_name = ptr;
> -		if (line_termination && path_name[0] == '"') {
> +		if (!nul_term_line && path_name[0] == '"') {

Yikes. The original used "line_termination" both as a character and as a
boolean. I think the postimage is much more obvious here.

> -		OPT_SET_INT('z', NULL, &line_termination,
> -			N_("with --stdin: input lines are terminated by null bytes"), '\0'),
> +		OPT_SET_INT('z', NULL, &nul_term_line,
> +			    N_("with --stdin: input lines are terminated by null bytes"), 1),

Should this just become OPT_BOOL now?

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