Skip to content

Commit 1876a5a

Browse files
five-shgitster
authored andcommitted
t4205: correctly test %(describe:abbrev=...)
The pretty format %(describe:abbrev=<number>) tells describe to use at least <number> digits of the oid to generate the human-readable format of the commit-ish. There are three things to test here: - Check that we can describe a commit that is not tagged (that is, for example our HEAD is at least one commit ahead of some reachable commit which is tagged) with at least <number> digits of the oid being used for describing it. - Check that when using such a commit-ish, we always use at least <number> digits of the oid to describe it. - Check that we can describe a tag. This just gives the name of the tag irrespective of abbrev (abbrev doesn't make sense here). Do this, instead of the current test which only tests the last case. Helped-by: Junio C Hamano <[email protected]> Mentored-by: Christian Couder <[email protected]> Mentored-by: Hariom Verma <[email protected]> Signed-off-by: Kousik Sanagavarapu <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9bbde12 commit 1876a5a

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

t/t4205-log-pretty-formats.sh

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1012,10 +1012,25 @@ test_expect_success '%(describe:tags) vs git describe --tags' '
10121012

10131013
test_expect_success '%(describe:abbrev=...) vs git describe --abbrev=...' '
10141014
test_when_finished "git tag -d tagname" &&
1015+
1016+
# Case 1: We have commits between HEAD and the most recent tag
1017+
# reachable from it
1018+
test_commit --no-tag file &&
1019+
git describe --abbrev=15 >expect &&
1020+
git log -1 --format="%(describe:abbrev=15)" >actual &&
1021+
test_cmp expect actual &&
1022+
1023+
# Make sure the hash used is at least 15 digits long
1024+
sed -e "s/^.*-g\([0-9a-f]*\)$/\1/" <actual >hexpart &&
1025+
test 16 -le $(wc -c <hexpart) &&
1026+
1027+
# Case 2: We have a tag at HEAD, describe directly gives the
1028+
# name of the tag
10151029
git tag -a -m tagged tagname &&
10161030
git describe --abbrev=15 >expect &&
10171031
git log -1 --format="%(describe:abbrev=15)" >actual &&
1018-
test_cmp expect actual
1032+
test_cmp expect actual &&
1033+
test tagname = $(cat actual)
10191034
'
10201035

10211036
test_expect_success 'log --pretty with space stealing' '

0 commit comments

Comments
 (0)