]>
Commit | Line | Data |
---|---|---|
0afc3044 JK |
1 | #!/bin/sh |
2 | ||
3 | test_description='git branch display tests' | |
4 | . ./test-lib.sh | |
5 | ||
6 | test_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 | ||
14 | test_expect_success 'make branches' ' | |
a48fcd83 | 15 | git branch branch-one && |
0afc3044 JK |
16 | git branch branch-two HEAD^ |
17 | ' | |
18 | ||
19 | test_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 | ||
25 | cat >expect <<'EOF' | |
26 | branch-one | |
27 | branch-two | |
28 | * master | |
29 | EOF | |
30 | test_expect_success 'git branch shows local branches' ' | |
31 | git branch >actual && | |
32 | test_cmp expect actual | |
33 | ' | |
34 | ||
35 | cat >expect <<'EOF' | |
36 | origin/HEAD -> origin/branch-one | |
37 | origin/branch-one | |
38 | origin/branch-two | |
39 | EOF | |
40 | test_expect_success 'git branch -r shows remote branches' ' | |
41 | git branch -r >actual && | |
42 | test_cmp expect actual | |
43 | ' | |
44 | ||
45 | cat >expect <<'EOF' | |
46 | branch-one | |
47 | branch-two | |
48 | * master | |
49 | remotes/origin/HEAD -> origin/branch-one | |
50 | remotes/origin/branch-one | |
51 | remotes/origin/branch-two | |
52 | EOF | |
53 | test_expect_success 'git branch -a shows local and remote branches' ' | |
54 | git branch -a >actual && | |
55 | test_cmp expect actual | |
56 | ' | |
57 | ||
58 | cat >expect <<'EOF' | |
59 | two | |
60 | one | |
61 | two | |
62 | EOF | |
63 | test_expect_success 'git branch -v shows branch summaries' ' | |
64 | git branch -v >tmp && | |
65 | awk "{print \$NF}" <tmp >actual && | |
66 | test_cmp expect actual | |
67 | ' | |
68 | ||
69 | cat >expect <<'EOF' | |
70 | * (no branch) | |
71 | branch-one | |
72 | branch-two | |
73 | master | |
74 | EOF | |
75 | test_expect_success 'git branch shows detached HEAD properly' ' | |
76 | git checkout HEAD^0 && | |
77 | git branch >actual && | |
78 | test_cmp expect actual | |
79 | ' | |
80 | ||
81 | test_done |