Skip to content

Commit 42cab60

Browse files
peffgitster
authored andcommitted
test combinations of @{} syntax
Now that we have several different types of @{} syntax, it is a good idea to test them together, which reveals some failures. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent af86deb commit 42cab60

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

t/t1508-at-combinations.sh

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/bin/sh
2+
3+
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+
"
12+
}
13+
nonsense() {
14+
test_expect_${2:-success} "$1 is nonsensical" "
15+
test_must_fail git log -1 '$1'
16+
"
17+
}
18+
fail() {
19+
"$@" failure
20+
}
21+
22+
test_expect_success 'setup' '
23+
test_commit master-one &&
24+
test_commit master-two &&
25+
git checkout -b upstream-branch &&
26+
test_commit upstream-one &&
27+
test_commit upstream-two &&
28+
git checkout -b old-branch &&
29+
test_commit old-one &&
30+
test_commit old-two &&
31+
git checkout -b new-branch &&
32+
test_commit new-one &&
33+
test_commit new-two &&
34+
git config branch.old-branch.remote . &&
35+
git config branch.old-branch.merge refs/heads/master &&
36+
git config branch.new-branch.remote . &&
37+
git config branch.new-branch.merge refs/heads/upstream-branch
38+
'
39+
40+
check HEAD new-two
41+
check "@{1}" new-one
42+
check "@{-1}" old-two
43+
check "@{-1}@{1}" old-one
44+
check "@{u}" upstream-two
45+
check "@{u}@{1}" upstream-one
46+
fail check "@{-1}@{u}" master-two
47+
fail check "@{-1}@{u}@{1}" master-one
48+
fail nonsense "@{u}@{-1}"
49+
nonsense "@{1}@{u}"
50+
51+
test_done

0 commit comments

Comments
 (0)