mirror of
https://github.com/git/git.git
synced 2026-03-01 19:16:25 +00:00
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'
This commit is contained in:
@@ -116,8 +116,6 @@ static int run_sequencer(int argc, const char **argv, struct replay_opts *opts)
|
||||
N_("option for merge strategy"), option_parse_x),
|
||||
{ OPTION_STRING, 'S', "gpg-sign", &opts->gpg_sign, N_("key-id"),
|
||||
N_("GPG sign commit"), PARSE_OPT_OPTARG, NULL, (intptr_t) "" },
|
||||
OPT_BOOL(0, "reference", &opts->commit_use_reference,
|
||||
N_("use the 'reference' format to refer to commits")),
|
||||
OPT_END()
|
||||
};
|
||||
struct option *options = base_options;
|
||||
@@ -132,6 +130,13 @@ static int run_sequencer(int argc, const char **argv, struct replay_opts *opts)
|
||||
OPT_END(),
|
||||
};
|
||||
options = parse_options_concat(options, cp_extra);
|
||||
} else if (opts->action == REPLAY_REVERT) {
|
||||
struct option cp_extra[] = {
|
||||
OPT_BOOL(0, "reference", &opts->commit_use_reference,
|
||||
N_("use the 'reference' format to refer to commits")),
|
||||
OPT_END(),
|
||||
};
|
||||
options = parse_options_concat(options, cp_extra);
|
||||
}
|
||||
|
||||
argc = parse_options(argc, argv, NULL, options, usage_str,
|
||||
|
||||
@@ -221,7 +221,7 @@ static int git_sequencer_config(const char *k, const char *v, void *cb)
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (!strcmp(k, "revert.reference"))
|
||||
if (opts->action == REPLAY_REVERT && !strcmp(k, "revert.reference"))
|
||||
opts->commit_use_reference = git_config_bool(k, v);
|
||||
|
||||
status = git_gpg_config(k, v, NULL);
|
||||
|
||||
@@ -204,4 +204,10 @@ test_expect_success 'identification of reverted commit (revert.reference)' '
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'cherry-pick is unaware of --reference (for now)' '
|
||||
test_when_finished "git reset --hard" &&
|
||||
test_must_fail git cherry-pick --reference HEAD 2>actual &&
|
||||
grep "^usage: git cherry-pick" actual
|
||||
'
|
||||
|
||||
test_done
|
||||
|
||||
Reference in New Issue
Block a user