Skip to content

Commit 3291fe4

Browse files
spearcegitster
authored andcommitted
Add git-describe test for "verify annotated tag names on output"
Back in 212945d ("Teach git-describe to verify annotated tag names before output") I taught git-describe to output the name shown in the "tag" header of an annotated tag, rather than the name it is actually stored under in this repository's ref namespace. This test case verifies this is working correctly by renaming the ref for an annotated tag to a different name that what is recorded in the tag body, and verifying that tag is returned. We also verify there is a message shown on stderr to inform the user that the tag is possibly stored under the wrong name locally. Signed-off-by: Shawn O. Pearce <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d1b28f5 commit 3291fe4

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

t/t6120-describe.sh

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ test_description='test describe
1515
check_describe () {
1616
expect="$1"
1717
shift
18-
R=$(git describe "$@")
18+
R=$(git describe "$@" 2>err.actual)
1919
S=$?
20+
cat err.actual >&3
2021
test_expect_success "describe $*" '
2122
test $S = 0 &&
2223
case "$R" in
@@ -98,6 +99,20 @@ check_describe B --tags HEAD^^2^
9899

99100
check_describe B-0-* --long HEAD^^2^
100101

102+
test_expect_success 'rename tag A to Q locally' '
103+
mv .git/refs/tags/A .git/refs/tags/Q
104+
'
105+
cat - >err.expect <<EOF
106+
warning: tag 'A' is really 'Q' here
107+
EOF
108+
check_describe A-* HEAD
109+
test_expect_success 'warning was displayed for Q' '
110+
git diff err.expect err.actual
111+
'
112+
test_expect_success 'rename tag Q back to A' '
113+
mv .git/refs/tags/Q .git/refs/tags/A
114+
'
115+
101116
test_expect_success 'pack tag refs' 'git pack-refs'
102117
check_describe A-* HEAD
103118

0 commit comments

Comments
 (0)