From 191faaf72648c4ed080a9e38c1782bc1619a6e87 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Tue, 31 May 2022 09:22:20 -0700 Subject: revert: --reference should apply only to 'revert', not 'cherry-pick' As 'revert' and 'cherry-pick' share a lot of code, it is easy to modify the behaviour of one command and inadvertently affect the other. An earlier change to teach the '--reference' option and the 'revert.reference' configuration variable to the former was not careful enough and 'cherry-pick --reference' wasn't rejected as an error. It is possible to think 'cherry-pick -x' might benefit from the '--reference' option, but it is fundamentally different from 'revert' in at least two ways to make it questionable: - 'revert' names a commit that is ancestor of the resulting commit, so an abbreviated object name with human readable title is sufficient to identify the named commit uniquely without using the full object name. On the other hand, 'cherry-pick' usually [*] picks a commit that is not an ancestor. It might be even picking a private commit that never becomes part of the public history. - The whole commit message of 'cherry-pick' is a copy of the original commit, and there is nothing gained to repeat only the title part on 'cherry-picked from' message. [*] well, you could revert and then you can pick the original that was reverted to get back to where you were, but then you can revert the revert to do the same thing. Helped-by: Phillip Wood Signed-off-by: Junio C Hamano --- sequencer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sequencer.c') diff --git a/sequencer.c b/sequencer.c index 96fec6ef6d..4b66a1f79c 100644 --- a/sequencer.c +++ b/sequencer.c @@ -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); -- cgit v1.3-5-g9baa