Merge branch 'jc/check-x-z'
authorJunio C Hamano <gitster@pobox.com>
Wed, 4 Sep 2013 19:23:24 +0000 (12:23 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 4 Sep 2013 19:23:25 +0000 (12:23 -0700)
"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

1  2 
Documentation/git-check-attr.txt
builtin/check-ignore.c
Simple merge
index 4a8fc707c747596e31dcc6f57abf5f965cdf612f,03e509e43d2766b8ae665f44f8ac87ba2fc4e7a8..503a559b18bf03aa7d78c2b408289da6297e0cff
@@@ -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);