interpret_branch_name: always respect "namelen" parameter
[git/git.git] / t / t1508-at-combinations.sh
CommitLineData
42cab601
JK
1#!/bin/sh
2
3test_description='test various @{X} syntax combinations together'
4. ./test-lib.sh
5
6check() {
c8a81e90
FC
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
8cd4249c
JK
12 elif test '$2' = 'ref'
13 then
c8a81e90 14 git rev-parse --symbolic-full-name '$1' >actual
8cd4249c
JK
15 else
16 git cat-file -p '$1' >actual
c8a81e90
FC
17 fi &&
18 test_cmp expect actual
19 "
42cab601 20}
c8a81e90 21
42cab601 22nonsense() {
c8a81e90 23 test_expect_${2:-success} "$1 is nonsensical" "
89d5dd4e 24 test_must_fail git rev-parse --verify '$1'
c8a81e90 25 "
42cab601 26}
c8a81e90 27
42cab601
JK
28fail() {
29 "$@" failure
30}
31
32test_expect_success 'setup' '
33 test_commit master-one &&
34 test_commit master-two &&
35 git checkout -b upstream-branch &&
36 test_commit upstream-one &&
37 test_commit upstream-two &&
9ba89f48
FC
38 git checkout -b @/at-test &&
39 git checkout -b @@/at-test &&
40 git checkout -b @at-test &&
42cab601
JK
41 git checkout -b old-branch &&
42 test_commit old-one &&
43 test_commit old-two &&
44 git checkout -b new-branch &&
45 test_commit new-one &&
46 test_commit new-two &&
1bc6d022
FC
47 git branch -u master old-branch &&
48 git branch -u upstream-branch new-branch
42cab601
JK
49'
50
c8a81e90
FC
51check HEAD ref refs/heads/new-branch
52check "@{1}" commit new-one
f58dc19e
RR
53check "HEAD@{1}" commit new-one
54check "@{now}" commit new-two
55check "HEAD@{now}" commit new-two
c8a81e90 56check "@{-1}" ref refs/heads/old-branch
f58dc19e 57check "@{-1}@{0}" commit old-two
c8a81e90
FC
58check "@{-1}@{1}" commit old-one
59check "@{u}" ref refs/heads/upstream-branch
f58dc19e 60check "HEAD@{u}" ref refs/heads/upstream-branch
c8a81e90
FC
61check "@{u}@{1}" commit upstream-one
62check "@{-1}@{u}" ref refs/heads/master
63check "@{-1}@{u}@{1}" commit master-one
9ba89f48
FC
64check "@" commit new-two
65check "@@{u}" ref refs/heads/upstream-branch
66check "@@/at-test" ref refs/heads/@@/at-test
67check "@/at-test" ref refs/heads/@/at-test
68check "@at-test" ref refs/heads/@at-test
12a258c0 69nonsense "@{u}@{-1}"
f58dc19e 70nonsense "@{0}@{0}"
42cab601 71nonsense "@{1}@{u}"
f58dc19e
RR
72nonsense "HEAD@{-1}"
73nonsense "@{-1}@{-1}"
42cab601 74
723b74ee
RR
75# @{N} versus HEAD@{N}
76
77check "HEAD@{3}" commit old-two
78nonsense "@{3}"
79
80test_expect_success 'switch to old-branch' '
81 git checkout old-branch
82'
83
84check HEAD ref refs/heads/old-branch
85check "HEAD@{1}" commit new-two
86check "@{1}" commit old-one
87
8cd4249c
JK
88test_expect_success 'create path with @' '
89 echo content >normal &&
90 echo content >fun@ny &&
91 git add normal fun@ny &&
92 git commit -m "funny path"
93'
94
95check "@:normal" blob content
96check "@:fun@ny" blob content
97
42cab601 98test_done