From: Junio C Hamano Date: Wed, 11 May 2011 22:14:13 +0000 (-0700) Subject: Merge branch 'jc/maint-1.6.6-pathspec-stdin-and-cmdline' X-Git-Tag: v1.7.6-rc0~44^2~3 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=25197ebe7f813407b028a2c304ff8ee58da40a16;p=git.git Merge branch 'jc/maint-1.6.6-pathspec-stdin-and-cmdline' * jc/maint-1.6.6-pathspec-stdin-and-cmdline: setup_revisions(): take pathspec from command line and --stdin correctly --- 25197ebe7f813407b028a2c304ff8ee58da40a16 diff --cc revision.c index 86d247048,047e01700..e571a3fd1 --- a/revision.c +++ b/revision.c @@@ -1432,44 -1256,16 +1431,16 @@@ void parse_revision_opt(struct rev_inf ctx->argc -= n; } -static int for_each_bad_bisect_ref(each_ref_fn fn, void *cb_data) +static int for_each_bad_bisect_ref(const char *submodule, each_ref_fn fn, void *cb_data) { - return for_each_ref_in("refs/bisect/bad", fn, cb_data); + return for_each_ref_in_submodule(submodule, "refs/bisect/bad", fn, cb_data); } -static int for_each_good_bisect_ref(each_ref_fn fn, void *cb_data) +static int for_each_good_bisect_ref(const char *submodule, each_ref_fn fn, void *cb_data) { - return for_each_ref_in("refs/bisect/good", fn, cb_data); + 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; - } - /* * Parse revision information, filling in the "rev_info" structure, * and removing the used arguments from the argument list. @@@ -1477,16 -1273,12 +1448,17 @@@ * Returns the number of arguments left that weren't recognized * (which are also moved to the head of the argument list) */ -int setup_revisions(int argc, const char **argv, struct rev_info *revs, const char *def) +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; + 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; + const char *optarg; + int argcount; + memset(&prune_data, 0, sizeof(prune_data)); + if (opt) + submodule = opt->submodule; /* First, search for "--" */ seen_dashdash = 0; @@@ -1612,20 -1379,19 +1584,24 @@@ append_prune_data(&prune_data, argv + i); break; } + else + got_rev_arg = 1; } - if (prune_data) - init_pathspec(&revs->prune_data, get_pathspec(revs->prefix, prune_data)); + if (prune_data.nr) { + ALLOC_GROW(prune_data.path, prune_data.nr+1, prune_data.alloc); + prune_data.path[prune_data.nr++] = NULL; - revs->prune_data = get_pathspec(revs->prefix, prune_data.path); ++ init_pathspec(&revs->prune_data, ++ get_pathspec(revs->prefix, prune_data.path)); + } if (revs->def == NULL) - revs->def = def; + revs->def = opt ? opt->def : NULL; + if (opt && opt->tweak) + opt->tweak(revs, opt); if (revs->show_merge) prepare_show_merge(revs); - if (revs->def && !revs->pending.nr) { + if (revs->def && !revs->pending.nr && !got_rev_arg) { unsigned char sha1[20]; struct object *object; unsigned mode;