Re: [PREVIEW v3 7/9] update-index: there are only two line terminators
From: Jeff King <hidden>
Date: 2016-06-15 23:07:45
On Wed, Jan 13, 2016 at 07:03:07PM -0800, Junio C Hamano wrote:
quoted hunk ↗ jump to hunk
-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