aboutsummaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorKristoffer Haugsbakk <code@khaugsbakk.name>2024-11-25 21:13:12 +0100
committerJunio C Hamano <gitster@pobox.com>2024-11-26 10:05:08 +0900
commit515d034f8d922602b9d417cdc02768757aa6f6c1 (patch)
tree986cc6b410098f0735cf33e172692b5a3118911b /t
parentsequencer: comment checked-out branch properly (diff)
downloadgit-515d034f8d922602b9d417cdc02768757aa6f6c1.tar.gz
git-515d034f8d922602b9d417cdc02768757aa6f6c1.zip
sequencer: comment `--reference` subject line properly
`git revert --reference <commit>` leaves behind a comment in the first line:[1] # *** SAY WHY WE ARE REVERTING ON THE TITLE LINE *** Meaning that the commit will just consist of the next line if the user exits the editor directly: This reverts commit <--format=reference commit> But the comment char here is hardcoded (#). Which means that the comment line will inadvertently be included in the commit message if `core.commentChar`/`core.commentString` is in use. † 1: See 43966ab3156 (revert: optionally refer to commit in the "reference" format, 2022-05-26) Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-xt/t3501-revert-cherry-pick.sh14
1 files changed, 14 insertions, 0 deletions
diff --git a/t/t3501-revert-cherry-pick.sh b/t/t3501-revert-cherry-pick.sh
index 411027fb58..b84fdfe8a3 100755
--- a/t/t3501-revert-cherry-pick.sh
+++ b/t/t3501-revert-cherry-pick.sh
@@ -228,6 +228,20 @@ test_expect_success 'identification of reverted commit (--reference)' '
test_cmp expect actual
'
+test_expect_success 'git revert --reference with core.commentChar' '
+ test_when_finished "git reset --hard to-ident" &&
+ git checkout --detach to-ident &&
+ GIT_EDITOR="head -n4 >actual" git -c core.commentChar=% revert \
+ --edit --reference HEAD &&
+ cat <<-EOF >expect &&
+ % *** SAY WHY WE ARE REVERTING ON THE TITLE LINE ***
+
+ This reverts commit $(git show -s --pretty=reference HEAD^).
+
+ EOF
+ test_cmp expect actual
+'
+
test_expect_success 'identification of reverted commit (revert.reference)' '
git checkout --detach to-ident &&
git -c revert.reference=true revert --no-edit HEAD &&