mirror of
https://github.com/git/git.git
synced 2024-10-28 12:59:41 +01:00
cherry-pick: do not expect file arguments
If a commit-ish passed to cherry-pick or revert happens to have a file of the same name, git complains that the argument is ambiguous and advises to use '--'. To make things worse, the '--' argument is removed by parse_options, und so passing '--' has no effect. Instead, always interpret cherry-pick/revert arguments as revisions. Signed-off-by: Clemens Buchacher <drizzd@aon.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
e8dde3e5f9
commit
6d5b93f29f
3 changed files with 19 additions and 11 deletions
|
@ -181,12 +181,15 @@ static void parse_args(int argc, const char **argv, struct replay_opts *opts)
|
|||
if (opts->subcommand != REPLAY_NONE) {
|
||||
opts->revs = NULL;
|
||||
} else {
|
||||
struct setup_revision_opt s_r_opt;
|
||||
opts->revs = xmalloc(sizeof(*opts->revs));
|
||||
init_revisions(opts->revs, NULL);
|
||||
opts->revs->no_walk = 1;
|
||||
if (argc < 2)
|
||||
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)
|
||||
|
|
|
@ -1715,6 +1715,9 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
|
|||
submodule = opt->submodule;
|
||||
|
||||
/* First, search for "--" */
|
||||
if (opt && opt->assume_dashdash) {
|
||||
seen_dashdash = 1;
|
||||
} else {
|
||||
seen_dashdash = 0;
|
||||
for (i = 1; i < argc; 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;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Second, deal with arguments and options */
|
||||
flags = 0;
|
||||
|
|
|
@ -183,6 +183,7 @@ struct setup_revision_opt {
|
|||
const char *def;
|
||||
void (*tweak)(struct rev_info *, struct setup_revision_opt *);
|
||||
const char *submodule;
|
||||
int assume_dashdash;
|
||||
};
|
||||
|
||||
extern void init_revisions(struct rev_info *revs, const char *prefix);
|
||||
|
|
Loading…
Reference in a new issue