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>
Felipe Contreras committed
May 7, 2013 at 16:55 UTC
c8a81e90acda9da55bae627928e80b04e98980fc
1 file changed
+23
-16
t/t1508-at-combinations.sh
+23
-16
@@ -4,17 +4,24 @@ test_description='test various @{X} syntax combinations together'
4
. ./test-lib.sh
5
6
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
+ "
17
}
18
+
19
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
+ "
23
}
24
+
25
fail() {
26
"$@" failure
27
}
@@ -35,14 +42,14 @@ test_expect_success 'setup' '
42
git branch -u upstream-branch new-branch
43
'
44
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
53
nonsense "@{u}@{-1}"
54
nonsense "@{1}@{u}"
55