Merge branch 'cb/cherry-pick-rev-path-confusion'

The command line parser choked "git cherry-pick $name" when $name can be
both revision name and a pathname, even though $name can never be a path
in the context of the command.

The issue the patch addresses is real, but the way it is implemented felt
unnecessarily invasive a bit.  It may be cleaner for this caller to add
the "--" to the end of the argv_array it passes to setup_revisions().

By Clemens Buchacher
* cb/cherry-pick-rev-path-confusion:
  cherry-pick: do not expect file arguments
This commit is contained in:
Junio C Hamano 2012-04-27 13:58:02 -07:00
commit 0fe59d7686
3 changed files with 19 additions and 11 deletions

View File

@ -182,12 +182,15 @@ static void parse_args(int argc, const char **argv, struct replay_opts *opts)
if (opts->subcommand != REPLAY_NONE) { if (opts->subcommand != REPLAY_NONE) {
opts->revs = NULL; opts->revs = NULL;
} else { } else {
struct setup_revision_opt s_r_opt;
opts->revs = xmalloc(sizeof(*opts->revs)); opts->revs = xmalloc(sizeof(*opts->revs));
init_revisions(opts->revs, NULL); init_revisions(opts->revs, NULL);
opts->revs->no_walk = 1; opts->revs->no_walk = 1;
if (argc < 2) if (argc < 2)
usage_with_options(usage_str, options); usage_with_options(usage_str, options);
argc = setup_revisions(argc, argv, opts->revs, NULL); memset(&s_r_opt, 0, sizeof(s_r_opt));
s_r_opt.assume_dashdash = 1;
argc = setup_revisions(argc, argv, opts->revs, &s_r_opt);
} }
if (argc > 1) if (argc > 1)

View File

@ -1715,6 +1715,9 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
submodule = opt->submodule; submodule = opt->submodule;
/* First, search for "--" */ /* First, search for "--" */
if (opt && opt->assume_dashdash) {
seen_dashdash = 1;
} else {
seen_dashdash = 0; seen_dashdash = 0;
for (i = 1; i < argc; i++) { for (i = 1; i < argc; i++) {
const char *arg = argv[i]; const char *arg = argv[i];
@ -1727,6 +1730,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
seen_dashdash = 1; seen_dashdash = 1;
break; break;
} }
}
/* Second, deal with arguments and options */ /* Second, deal with arguments and options */
flags = 0; flags = 0;

View File

@ -183,6 +183,7 @@ struct setup_revision_opt {
const char *def; const char *def;
void (*tweak)(struct rev_info *, struct setup_revision_opt *); void (*tweak)(struct rev_info *, struct setup_revision_opt *);
const char *submodule; const char *submodule;
int assume_dashdash;
}; };
extern void init_revisions(struct rev_info *revs, const char *prefix); extern void init_revisions(struct rev_info *revs, const char *prefix);