3 test_description
='git branch display tests'
6 test_expect_success
'make commits' '
10 echo content >>file &&
14 test_expect_success
'make branches' '
15 git branch branch-one &&
16 git branch branch-two HEAD^
19 test_expect_success
'make remote branches' '
20 git update-ref refs/remotes/origin/branch-one branch-one &&
21 git update-ref refs/remotes/origin/branch-two branch-two &&
22 git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/branch-one
30 test_expect_success
'git branch shows local branches' '
32 test_cmp expect actual
35 test_expect_success
'git branch --list shows local branches' '
36 git branch --list >actual &&
37 test_cmp expect actual
44 test_expect_success
'git branch --list pattern shows matching local branches' '
45 git branch --list branch* >actual &&
46 test_cmp expect actual
50 origin/HEAD -> origin/branch-one
54 test_expect_success
'git branch -r shows remote branches' '
55 git branch -r >actual &&
56 test_cmp expect actual
63 remotes/origin/HEAD -> origin/branch-one
64 remotes/origin/branch-one
65 remotes/origin/branch-two
67 test_expect_success
'git branch -a shows local and remote branches' '
68 git branch -a >actual &&
69 test_cmp expect actual
77 test_expect_success
'git branch -v shows branch summaries' '
79 awk "{print \$NF}" <tmp >actual &&
80 test_cmp expect actual
87 test_expect_success
'git branch --list -v pattern shows branch summaries' '
88 git branch --list -v branch* >tmp &&
89 awk "{print \$NF}" <tmp >actual &&
90 test_cmp expect actual
93 test_expect_success
'git branch -v pattern does not show branch summaries' '
94 test_must_fail git branch -v branch*
97 test_expect_success
'git branch shows detached HEAD properly' '
99 * (HEAD detached at $(git rev-parse --short HEAD^0))
104 git checkout HEAD^0 &&
105 git branch >actual &&
106 test_i18ncmp expect actual
109 test_expect_success
'git branch shows detached HEAD properly after checkout --detach' '
110 git checkout master &&
112 * (HEAD detached at $(git rev-parse --short HEAD^0))
117 git checkout --detach &&
118 git branch >actual &&
119 test_i18ncmp expect actual
122 test_expect_success
'git branch shows detached HEAD properly after moving' '
124 * (HEAD detached from $(git rev-parse --short HEAD))
129 git reset --hard HEAD^1 &&
130 git branch >actual &&
131 test_i18ncmp expect actual
134 test_expect_success
'git branch shows detached HEAD properly from tag' '
136 * (HEAD detached at fromtag)
141 git tag fromtag master &&
142 git checkout fromtag &&
143 git branch >actual &&
144 test_i18ncmp expect actual
147 test_expect_success
'git branch shows detached HEAD properly after moving from tag' '
149 * (HEAD detached from fromtag)
154 git reset --hard HEAD^1 &&
155 git branch >actual &&
156 test_i18ncmp expect actual
159 test_expect_success
'git branch `--sort` option' '
160 cat >expect <<-\EOF &&
161 * (HEAD detached from fromtag)
166 git branch --sort=objectsize >actual &&
167 test_i18ncmp expect actual
170 test_expect_success
'git branch --points-at option' '
171 cat >expect <<-\EOF &&
175 git branch --points-at=branch-one >actual &&
176 test_cmp expect actual
179 test_expect_success
'ambiguous branch/tag not marked' '
181 git branch ambiguous &&
182 echo " ambiguous" >expect &&
183 git branch --list ambiguous >actual &&
184 test_cmp expect actual
187 test_expect_success
'local-branch symrefs shortened properly' '
188 git symbolic-ref refs/heads/ref-to-branch refs/heads/branch-one &&
189 git symbolic-ref refs/heads/ref-to-remote refs/remotes/origin/branch-one &&
190 cat >expect <<-\EOF &&
191 ref-to-branch -> branch-one
192 ref-to-remote -> refs/remotes/origin/branch-one
194 git branch >actual.raw &&
195 grep ref-to <actual.raw >actual &&
196 test_cmp expect actual