diff options
author | Junio C Hamano <gitster@pobox.com> | 2022-05-31 18:22:20 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-05-31 18:40:51 +0200 |
commit | 191faaf72648c4ed080a9e38c1782bc1619a6e87 (patch) | |
tree | ffd044190d721995fe6ba7896395a7b1b44ae07f /t | |
parent | revert: optionally refer to commit in the "reference" format (diff) | |
download | git-191faaf72648c4ed080a9e38c1782bc1619a6e87.tar.xz git-191faaf72648c4ed080a9e38c1782bc1619a6e87.zip |
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 <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-x | t/t3501-revert-cherry-pick.sh | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/t/t3501-revert-cherry-pick.sh b/t/t3501-revert-cherry-pick.sh index a386ae9e88..fb4466599b 100755 --- a/t/t3501-revert-cherry-pick.sh +++ b/t/t3501-revert-cherry-pick.sh @@ -205,4 +205,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 |