From: Junio C Hamano Date: Wed, 25 May 2011 23:23:22 +0000 (-0700) Subject: Merge branch 'js/log-abbrev-commit-config' X-Git-Tag: v1.7.6-rc0~32 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/84da3e21dc008fe7ba18811e8b7f7614ede33079?ds=inline;hp=-c Merge branch 'js/log-abbrev-commit-config' * js/log-abbrev-commit-config: Add log.abbrevCommit config variable "git log -h": typofix misspelled 'suppress' --- 84da3e21dc008fe7ba18811e8b7f7614ede33079 diff --combined revision.c index 7934b2f68b,be74bf92f5..7588a60b8e --- a/revision.c +++ b/revision.c @@@ -1098,34 -1098,35 +1098,34 @@@ int handle_revision_arg(const char *arg return 0; } -static void read_pathspec_from_stdin(struct rev_info *revs, struct strbuf *sb, const char ***prune_data) -{ - const char **prune = *prune_data; - int prune_nr; - int prune_alloc; +struct cmdline_pathspec { + int alloc; + int nr; + const char **path; +}; - /* count existing ones */ - if (!prune) - prune_nr = 0; - else - for (prune_nr = 0; prune[prune_nr]; prune_nr++) - ; - prune_alloc = prune_nr; /* not really, but we do not know */ +static void append_prune_data(struct cmdline_pathspec *prune, const char **av) +{ + while (*av) { + ALLOC_GROW(prune->path, prune->nr+1, prune->alloc); + prune->path[prune->nr++] = *(av++); + } +} +static void read_pathspec_from_stdin(struct rev_info *revs, struct strbuf *sb, + struct cmdline_pathspec *prune) +{ while (strbuf_getwholeline(sb, stdin, '\n') != EOF) { int len = sb->len; if (len && sb->buf[len - 1] == '\n') sb->buf[--len] = '\0'; - ALLOC_GROW(prune, prune_nr+1, prune_alloc); - prune[prune_nr++] = xstrdup(sb->buf); - } - if (prune) { - ALLOC_GROW(prune, prune_nr+1, prune_alloc); - prune[prune_nr] = NULL; + ALLOC_GROW(prune->path, prune->nr+1, prune->alloc); + prune->path[prune->nr++] = xstrdup(sb->buf); } - *prune_data = prune; } -static void read_revisions_from_stdin(struct rev_info *revs, const char ***prune) +static void read_revisions_from_stdin(struct rev_info *revs, + struct cmdline_pathspec *prune) { struct strbuf sb; int seen_dashdash = 0; @@@ -1428,6 -1429,9 +1428,9 @@@ static int handle_revision_opt(struct r revs->abbrev = 40; } else if (!strcmp(arg, "--abbrev-commit")) { revs->abbrev_commit = 1; + revs->abbrev_commit_given = 1; + } else if (!strcmp(arg, "--no-abbrev-commit")) { + revs->abbrev_commit = 0; } else if (!strcmp(arg, "--full-diff")) { revs->diff = 1; revs->full_diff = 1; @@@ -1508,6 -1512,34 +1511,6 @@@ static int for_each_good_bisect_ref(con return for_each_ref_in_submodule(submodule, "refs/bisect/good", fn, cb_data); } -static void append_prune_data(const char ***prune_data, const char **av) -{ - const char **prune = *prune_data; - int prune_nr; - int prune_alloc; - - if (!prune) { - *prune_data = av; - return; - } - - /* count existing ones */ - for (prune_nr = 0; prune[prune_nr]; prune_nr++) - ; - prune_alloc = prune_nr; /* not really, but we do not know */ - - while (*av) { - ALLOC_GROW(prune, prune_nr+1, prune_alloc); - prune[prune_nr++] = *av; - av++; - } - if (prune) { - ALLOC_GROW(prune, prune_nr+1, prune_alloc); - prune[prune_nr] = NULL; - } - *prune_data = prune; -} - static int handle_revision_pseudo_opt(const char *submodule, struct rev_info *revs, int argc, const char **argv, int *flags) @@@ -1581,10 -1613,9 +1584,10 @@@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct setup_revision_opt *opt) { int i, flags, left, seen_dashdash, read_from_stdin, got_rev_arg = 0; - const char **prune_data = NULL; + struct cmdline_pathspec prune_data; const char *submodule = NULL; + memset(&prune_data, 0, sizeof(prune_data)); if (opt) submodule = opt->submodule; @@@ -1597,7 -1628,7 +1600,7 @@@ argv[i] = NULL; argc = i; if (argv[i + 1]) - prune_data = argv + i + 1; + append_prune_data(&prune_data, argv + i + 1); seen_dashdash = 1; break; } @@@ -1660,26 -1691,8 +1663,26 @@@ got_rev_arg = 1; } - if (prune_data) - init_pathspec(&revs->prune_data, get_pathspec(revs->prefix, prune_data)); + if (prune_data.nr) { + /* + * If we need to introduce the magic "a lone ':' means no + * pathspec whatsoever", here is the place to do so. + * + * if (prune_data.nr == 1 && !strcmp(prune_data[0], ":")) { + * prune_data.nr = 0; + * prune_data.alloc = 0; + * free(prune_data.path); + * prune_data.path = NULL; + * } else { + * terminate prune_data.alloc with NULL and + * call init_pathspec() to set revs->prune_data here. + * } + */ + ALLOC_GROW(prune_data.path, prune_data.nr+1, prune_data.alloc); + prune_data.path[prune_data.nr++] = NULL; + init_pathspec(&revs->prune_data, + get_pathspec(revs->prefix, prune_data.path)); + } if (revs->def == NULL) revs->def = opt ? opt->def : NULL;