Skip to content

Commit c8a81e9

Browse files
Felipe Contrerasgitster
authored andcommitted
tests: at-combinations: check ref names directly
Some committishes might point to the same commit, but through a different ref, that's why it's better to check directly for the ref, rather than the commit message. We can do that by calling rev-parse --symbolic-full-name, and to differentiate the old from the new behavior we add an extra argument to the check() helper. Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 1bc6d02 commit c8a81e9

1 file changed

Lines changed: 23 additions & 16 deletions

File tree

t/t1508-at-combinations.sh

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,24 @@ test_description='test various @{X} syntax combinations together'
44
. ./test-lib.sh
55

66
check() {
7-
test_expect_${3:-success} "$1 = $2" "
8-
echo '$2' >expect &&
9-
git log -1 --format=%s '$1' >actual &&
10-
test_cmp expect actual
11-
"
7+
test_expect_${4:-success} "$1 = $3" "
8+
echo '$3' >expect &&
9+
if test '$2' = 'commit'
10+
then
11+
git log -1 --format=%s '$1' >actual
12+
else
13+
git rev-parse --symbolic-full-name '$1' >actual
14+
fi &&
15+
test_cmp expect actual
16+
"
1217
}
18+
1319
nonsense() {
14-
test_expect_${2:-success} "$1 is nonsensical" "
15-
test_must_fail git log -1 '$1'
16-
"
20+
test_expect_${2:-success} "$1 is nonsensical" "
21+
test_must_fail git log -1 '$1'
22+
"
1723
}
24+
1825
fail() {
1926
"$@" failure
2027
}
@@ -35,14 +42,14 @@ test_expect_success 'setup' '
3542
git branch -u upstream-branch new-branch
3643
'
3744

38-
check HEAD new-two
39-
check "@{1}" new-one
40-
check "@{-1}" old-two
41-
check "@{-1}@{1}" old-one
42-
check "@{u}" upstream-two
43-
check "@{u}@{1}" upstream-one
44-
check "@{-1}@{u}" master-two
45-
check "@{-1}@{u}@{1}" master-one
45+
check HEAD ref refs/heads/new-branch
46+
check "@{1}" commit new-one
47+
check "@{-1}" ref refs/heads/old-branch
48+
check "@{-1}@{1}" commit old-one
49+
check "@{u}" ref refs/heads/upstream-branch
50+
check "@{u}@{1}" commit upstream-one
51+
check "@{-1}@{u}" ref refs/heads/master
52+
check "@{-1}@{u}@{1}" commit master-one
4653
nonsense "@{u}@{-1}"
4754
nonsense "@{1}@{u}"
4855

0 commit comments

Comments
 (0)