Skip to content

Commit 0fe59d7

Browse files
committed
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
2 parents 157a476 + 6d5b93f commit 0fe59d7

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

builtin/revert.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,12 +182,15 @@ static void parse_args(int argc, const char **argv, struct replay_opts *opts)
182182
if (opts->subcommand != REPLAY_NONE) {
183183
opts->revs = NULL;
184184
} else {
185+
struct setup_revision_opt s_r_opt;
185186
opts->revs = xmalloc(sizeof(*opts->revs));
186187
init_revisions(opts->revs, NULL);
187188
opts->revs->no_walk = 1;
188189
if (argc < 2)
189190
usage_with_options(usage_str, options);
190-
argc = setup_revisions(argc, argv, opts->revs, NULL);
191+
memset(&s_r_opt, 0, sizeof(s_r_opt));
192+
s_r_opt.assume_dashdash = 1;
193+
argc = setup_revisions(argc, argv, opts->revs, &s_r_opt);
191194
}
192195

193196
if (argc > 1)

revision.c

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1715,17 +1715,21 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
17151715
submodule = opt->submodule;
17161716

17171717
/* First, search for "--" */
1718-
seen_dashdash = 0;
1719-
for (i = 1; i < argc; i++) {
1720-
const char *arg = argv[i];
1721-
if (strcmp(arg, "--"))
1722-
continue;
1723-
argv[i] = NULL;
1724-
argc = i;
1725-
if (argv[i + 1])
1726-
append_prune_data(&prune_data, argv + i + 1);
1718+
if (opt && opt->assume_dashdash) {
17271719
seen_dashdash = 1;
1728-
break;
1720+
} else {
1721+
seen_dashdash = 0;
1722+
for (i = 1; i < argc; i++) {
1723+
const char *arg = argv[i];
1724+
if (strcmp(arg, "--"))
1725+
continue;
1726+
argv[i] = NULL;
1727+
argc = i;
1728+
if (argv[i + 1])
1729+
append_prune_data(&prune_data, argv + i + 1);
1730+
seen_dashdash = 1;
1731+
break;
1732+
}
17291733
}
17301734

17311735
/* Second, deal with arguments and options */

revision.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ struct setup_revision_opt {
183183
const char *def;
184184
void (*tweak)(struct rev_info *, struct setup_revision_opt *);
185185
const char *submodule;
186+
int assume_dashdash;
186187
};
187188

188189
extern void init_revisions(struct rev_info *revs, const char *prefix);

0 commit comments

Comments
 (0)