Skip to content

Commit e405211

Browse files
committed
Merge branch 'jc/revert-show-parent-info' into next
"git revert" learns "--reference" option to use more human-readable reference to the commit it reverts in the message template it prepares for the user. * jc/revert-show-parent-info: revert: --reference should apply only to 'revert', not 'cherry-pick'
2 parents e1c1e0b + 191faaf commit e405211

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

builtin/revert.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,6 @@ static int run_sequencer(int argc, const char **argv, struct replay_opts *opts)
116116
N_("option for merge strategy"), option_parse_x),
117117
{ OPTION_STRING, 'S', "gpg-sign", &opts->gpg_sign, N_("key-id"),
118118
N_("GPG sign commit"), PARSE_OPT_OPTARG, NULL, (intptr_t) "" },
119-
OPT_BOOL(0, "reference", &opts->commit_use_reference,
120-
N_("use the 'reference' format to refer to commits")),
121119
OPT_END()
122120
};
123121
struct option *options = base_options;
@@ -132,6 +130,13 @@ static int run_sequencer(int argc, const char **argv, struct replay_opts *opts)
132130
OPT_END(),
133131
};
134132
options = parse_options_concat(options, cp_extra);
133+
} else if (opts->action == REPLAY_REVERT) {
134+
struct option cp_extra[] = {
135+
OPT_BOOL(0, "reference", &opts->commit_use_reference,
136+
N_("use the 'reference' format to refer to commits")),
137+
OPT_END(),
138+
};
139+
options = parse_options_concat(options, cp_extra);
135140
}
136141

137142
argc = parse_options(argc, argv, NULL, options, usage_str,

sequencer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ static int git_sequencer_config(const char *k, const char *v, void *cb)
221221
return ret;
222222
}
223223

224-
if (!strcmp(k, "revert.reference"))
224+
if (opts->action == REPLAY_REVERT && !strcmp(k, "revert.reference"))
225225
opts->commit_use_reference = git_config_bool(k, v);
226226

227227
status = git_gpg_config(k, v, NULL);

t/t3501-revert-cherry-pick.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,4 +204,10 @@ test_expect_success 'identification of reverted commit (revert.reference)' '
204204
test_cmp expect actual
205205
'
206206

207+
test_expect_success 'cherry-pick is unaware of --reference (for now)' '
208+
test_when_finished "git reset --hard" &&
209+
test_must_fail git cherry-pick --reference HEAD 2>actual &&
210+
grep "^usage: git cherry-pick" actual
211+
'
212+
207213
test_done

0 commit comments

Comments
 (0)