Re: [PREVIEW v3 7/9] update-index: there are only two line terminators
- From
Jeff King <peff@peff.net>
- Date
- Jan 14, 2016, 10:09 UTC
- Message-ID
- <20160114100907.GA30772@sigill.intra.peff.net>
- In-Reply-To
- <1452740590-16827-8-git-send-email-gitster@pobox.com>
On Wed, Jan 13, 2016 at 07:03:07PM -0800, Junio C Hamano wrote:
Show 19 quoted lines
> -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