From: Junio C Hamano Date: Wed, 4 Sep 2013 19:23:24 +0000 (-0700) Subject: Merge branch 'jc/check-x-z' X-Git-Tag: v1.8.5-rc0~197 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0db320d023ea41b201edd4bbf67a2e275726f705;p=thirdparty%2Fgit.git Merge branch 'jc/check-x-z' "git check-ignore -z" applied the NUL termination to both its input (with --stdin) and its output, but "git check-attr -z" ignored the option on the output side. This is potentially a backward incompatible fix. Let's see if anybody screams before deciding if we want to do anything to help existing users (there may be none). * jc/check-x-z: check-attr -z: a single -z should apply to both input and output check-ignore -z: a single -z should apply to both input and output check-attr: the name of the character is NUL, not NULL check-ignore: the name of the character is NUL, not NULL --- 0db320d023ea41b201edd4bbf67a2e275726f705 diff --cc builtin/check-ignore.c index 4a8fc707c7,03e509e43d..503a559b18 --- a/builtin/check-ignore.c +++ b/builtin/check-ignore.c @@@ -20,18 -20,16 +20,18 @@@ static const struct option check_ignore OPT_GROUP(""), OPT_BOOLEAN(0, "stdin", &stdin_paths, N_("read file names from stdin")), - OPT_BOOLEAN('z', NULL, &null_term_line, - N_("input paths are terminated by a null character")), + OPT_BOOLEAN('z', NULL, &nul_term_line, + N_("terminate input and output records by a NUL character")), + OPT_BOOLEAN('n', "non-matching", &show_non_matching, + N_("show non-matching input paths")), OPT_END() }; static void output_exclude(const char *path, struct exclude *exclude) { - char *bang = exclude->flags & EXC_FLAG_NEGATIVE ? "!" : ""; - char *slash = exclude->flags & EXC_FLAG_MUSTBEDIR ? "/" : ""; + char *bang = (exclude && exclude->flags & EXC_FLAG_NEGATIVE) ? "!" : ""; + char *slash = (exclude && exclude->flags & EXC_FLAG_MUSTBEDIR) ? "/" : ""; - if (!null_term_line) { + if (!nul_term_line) { if (!verbose) { write_name_quoted(path, stdout, '\n'); } else { @@@ -103,12 -106,13 +103,12 @@@ static int check_ignore(struct dir_stru return num_ignored; } -static int check_ignore_stdin_paths(const char *prefix) +static int check_ignore_stdin_paths(struct dir_struct *dir, const char *prefix) { struct strbuf buf, nbuf; - char **pathspec = NULL; - size_t nr = 0, alloc = 0; + char *pathspec[2] = { NULL, NULL }; - int line_termination = null_term_line ? 0 : '\n'; + int line_termination = nul_term_line ? 0 : '\n'; - int num_ignored; + int num_ignored = 0; strbuf_init(&buf, 0); strbuf_init(&nbuf, 0);