Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2022-06-16 01:09:27 +0300
committerJunio C Hamano <gitster@pobox.com>2022-06-16 01:09:27 +0300
commitbfca6316345ffd717c717d2e36365239a3070124 (patch)
tree3019c0b1c54e5d7a34f947cdfc2f16a0aaa4be48 /t/t3501-revert-cherry-pick.sh
parent7596fe952d92f06375b1ef9fcde1b03c97d23983 (diff)
parent191faaf72648c4ed080a9e38c1782bc1619a6e87 (diff)
Merge branch 'jc/revert-show-parent-info'
"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' revert: optionally refer to commit in the "reference" format
Diffstat (limited to 't/t3501-revert-cherry-pick.sh')
-rwxr-xr-xt/t3501-revert-cherry-pick.sh37
1 files changed, 37 insertions, 0 deletions
diff --git a/t/t3501-revert-cherry-pick.sh b/t/t3501-revert-cherry-pick.sh
index 9eb19204ac..1f4cfc3744 100755
--- a/t/t3501-revert-cherry-pick.sh
+++ b/t/t3501-revert-cherry-pick.sh
@@ -158,6 +158,7 @@ test_expect_success 'cherry-pick works with dirty renamed file' '
'
test_expect_success 'advice from failed revert' '
+ test_when_finished "git reset --hard" &&
test_commit --no-tag "add dream" dream dream &&
dream_oid=$(git rev-parse --short HEAD) &&
cat <<-EOF >expected &&
@@ -173,4 +174,40 @@ test_expect_success 'advice from failed revert' '
test_must_fail git revert HEAD^ 2>actual &&
test_cmp expected actual
'
+
+test_expect_success 'identification of reverted commit (default)' '
+ test_commit to-ident &&
+ test_when_finished "git reset --hard to-ident" &&
+ git checkout --detach to-ident &&
+ git revert --no-edit HEAD &&
+ git cat-file commit HEAD >actual.raw &&
+ grep "^This reverts " actual.raw >actual &&
+ echo "This reverts commit $(git rev-parse HEAD^)." >expect &&
+ test_cmp expect actual
+'
+
+test_expect_success 'identification of reverted commit (--reference)' '
+ git checkout --detach to-ident &&
+ git revert --reference --no-edit HEAD &&
+ git cat-file commit HEAD >actual.raw &&
+ grep "^This reverts " actual.raw >actual &&
+ echo "This reverts commit $(git show -s --pretty=reference HEAD^)." >expect &&
+ 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 &&
+ git cat-file commit HEAD >actual.raw &&
+ grep "^This reverts " actual.raw >actual &&
+ echo "This reverts commit $(git show -s --pretty=reference HEAD^)." >expect &&
+ 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