branch: introduce --list option
[git/git.git] / t / t3203-branch-output.sh
CommitLineData
0afc3044
JK
1#!/bin/sh
2
3test_description='git branch display tests'
4. ./test-lib.sh
5
6test_expect_success 'make commits' '
7 echo content >file &&
8 git add file &&
9 git commit -m one &&
10 echo content >>file &&
11 git commit -a -m two
12'
13
14test_expect_success 'make branches' '
a48fcd83 15 git branch branch-one &&
0afc3044
JK
16 git branch branch-two HEAD^
17'
18
19test_expect_success 'make remote branches' '
a48fcd83
JN
20 git update-ref refs/remotes/origin/branch-one branch-one &&
21 git update-ref refs/remotes/origin/branch-two branch-two &&
0afc3044
JK
22 git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/branch-one
23'
24
25cat >expect <<'EOF'
26 branch-one
27 branch-two
28* master
29EOF
30test_expect_success 'git branch shows local branches' '
31 git branch >actual &&
32 test_cmp expect actual
33'
34
cddd127b
MG
35test_expect_success 'git branch --list shows local branches' '
36 git branch --list >actual &&
37 test_cmp expect actual
38'
39
0afc3044
JK
40cat >expect <<'EOF'
41 origin/HEAD -> origin/branch-one
42 origin/branch-one
43 origin/branch-two
44EOF
45test_expect_success 'git branch -r shows remote branches' '
46 git branch -r >actual &&
47 test_cmp expect actual
48'
49
50cat >expect <<'EOF'
51 branch-one
52 branch-two
53* master
54 remotes/origin/HEAD -> origin/branch-one
55 remotes/origin/branch-one
56 remotes/origin/branch-two
57EOF
58test_expect_success 'git branch -a shows local and remote branches' '
59 git branch -a >actual &&
60 test_cmp expect actual
61'
62
63cat >expect <<'EOF'
64two
65one
66two
67EOF
68test_expect_success 'git branch -v shows branch summaries' '
69 git branch -v >tmp &&
70 awk "{print \$NF}" <tmp >actual &&
71 test_cmp expect actual
72'
73
74cat >expect <<'EOF'
75* (no branch)
76 branch-one
77 branch-two
78 master
79EOF
fff1bb3a 80test_expect_success 'git branch shows detached HEAD properly' '
0afc3044
JK
81 git checkout HEAD^0 &&
82 git branch >actual &&
fff1bb3a 83 test_i18ncmp expect actual
0afc3044
JK
84'
85
86test_done