]> git.ipfire.org Git - thirdparty/git.git/blame - t/t3202-show-branch.sh
Merge branch 'en/fetch-negotiation-default-fix'
[thirdparty/git.git] / t / t3202-show-branch.sh
CommitLineData
ce567d18
JS
1#!/bin/sh
2
4f5ce122 3test_description='test show-branch'
ce567d18
JS
4
5. ./test-lib.sh
6
f2463490
HWN
7# arbitrary reference time: 2009-08-30 19:20:00
8GIT_TEST_DATE_NOW=1251660000; export GIT_TEST_DATE_NOW
9
ce567d18 10test_expect_success 'setup' '
9b6e74a9
ÆAB
11 test_commit initial &&
12 for i in $(test_seq 1 10)
ce567d18 13 do
9b6e74a9 14 git checkout -b branch$i initial &&
db5875aa 15 test_commit --no-tag branch$i || return 1
9b6e74a9
ÆAB
16 done &&
17 git for-each-ref \
18 --sort=version:refname \
19 --format="%(refname:strip=2)" \
20 "refs/heads/branch*" >branches.sorted &&
21 sed "s/^> //" >expect <<-\EOF
22 > ! [branch1] branch1
23 > ! [branch2] branch2
24 > ! [branch3] branch3
25 > ! [branch4] branch4
26 > ! [branch5] branch5
27 > ! [branch6] branch6
28 > ! [branch7] branch7
29 > ! [branch8] branch8
30 > ! [branch9] branch9
31 > * [branch10] branch10
32 > ----------
33 > * [branch10] branch10
34 > + [branch9] branch9
35 > + [branch8] branch8
36 > + [branch7] branch7
37 > + [branch6] branch6
38 > + [branch5] branch5
39 > + [branch4] branch4
40 > + [branch3] branch3
41 > + [branch2] branch2
42 > + [branch1] branch1
43 > +++++++++* [branch10^] initial
44 EOF
ce567d18
JS
45'
46
e358f3c3 47test_expect_success 'show-branch with more than 8 branches' '
9b6e74a9
ÆAB
48 git show-branch $(cat branches.sorted) >actual &&
49 test_cmp expect actual
ce567d18
JS
50'
51
3af1cae4 52test_expect_success 'show-branch with showbranch.default' '
9b6e74a9
ÆAB
53 for branch in $(cat branches.sorted)
54 do
db5875aa 55 test_config showbranch.default $branch --add || return 1
3af1cae4 56 done &&
9b6e74a9
ÆAB
57 git show-branch >actual &&
58 test_cmp expect actual
3af1cae4
JH
59'
60
4465690c
ÆAB
61test_expect_success 'show-branch --color output' '
62 sed "s/^> //" >expect <<-\EOF &&
63 > <RED>!<RESET> [branch1] branch1
64 > <GREEN>!<RESET> [branch2] branch2
65 > <YELLOW>!<RESET> [branch3] branch3
66 > <BLUE>!<RESET> [branch4] branch4
67 > <MAGENTA>!<RESET> [branch5] branch5
68 > <CYAN>!<RESET> [branch6] branch6
69 > <BOLD;RED>!<RESET> [branch7] branch7
70 > <BOLD;GREEN>!<RESET> [branch8] branch8
71 > <BOLD;YELLOW>!<RESET> [branch9] branch9
72 > <BOLD;BLUE>*<RESET> [branch10] branch10
73 > ----------
74 > <BOLD;BLUE>*<RESET> [branch10] branch10
75 > <BOLD;YELLOW>+<RESET> [branch9] branch9
76 > <BOLD;GREEN>+<RESET> [branch8] branch8
77 > <BOLD;RED>+<RESET> [branch7] branch7
78 > <CYAN>+<RESET> [branch6] branch6
79 > <MAGENTA>+<RESET> [branch5] branch5
80 > <BLUE>+<RESET> [branch4] branch4
81 > <YELLOW>+<RESET> [branch3] branch3
82 > <GREEN>+<RESET> [branch2] branch2
83 > <RED>+<RESET> [branch1] branch1
84 > <RED>+<RESET><GREEN>+<RESET><YELLOW>+<RESET><BLUE>+<RESET><MAGENTA>+<RESET><CYAN>+<RESET><BOLD;RED>+<RESET><BOLD;GREEN>+<RESET><BOLD;YELLOW>+<RESET><BOLD;BLUE>*<RESET> [branch10^] initial
85 EOF
86 git show-branch --color=always $(cat branches.sorted) >actual.raw &&
87 test_decode_color <actual.raw >actual &&
88 test_cmp expect actual
89'
90
d65aea37
ÆAB
91test_expect_success 'show branch --remotes' '
92 cat >expect.err <<-\EOF &&
93 No revs to be shown.
94 EOF
95 git show-branch -r 2>actual.err >actual.out &&
96 test_cmp expect.err actual.err &&
97 test_must_be_empty actual.out
98'
99
100test_expect_success 'setup show branch --list' '
101 sed "s/^> //" >expect <<-\EOF
102 > [branch1] branch1
103 > [branch2] branch2
104 > [branch3] branch3
105 > [branch4] branch4
106 > [branch5] branch5
107 > [branch6] branch6
108 > [branch7] branch7
109 > [branch8] branch8
110 > [branch9] branch9
111 > * [branch10] branch10
112 EOF
113'
114
115test_expect_success 'show branch --list' '
116 git show-branch --list $(cat branches.sorted) >actual &&
117 test_cmp expect actual
118'
119
120test_expect_success 'show branch --list has no --color output' '
121 git show-branch --color=always --list $(cat branches.sorted) >actual &&
122 test_cmp expect actual
123'
124
125test_expect_success 'show branch --merge-base with one argument' '
126 for branch in $(cat branches.sorted)
127 do
128 git rev-parse $branch >expect &&
129 git show-branch --merge-base $branch >actual &&
db5875aa 130 test_cmp expect actual || return 1
d65aea37
ÆAB
131 done
132'
133
134test_expect_success 'show branch --merge-base with two arguments' '
135 for branch in $(cat branches.sorted)
136 do
137 git rev-parse initial >expect &&
138 git show-branch --merge-base initial $branch >actual &&
db5875aa 139 test_cmp expect actual || return 1
d65aea37
ÆAB
140 done
141'
142
143test_expect_success 'show branch --merge-base with N arguments' '
144 git rev-parse initial >expect &&
145 git show-branch --merge-base $(cat branches.sorted) >actual &&
146 test_cmp expect actual &&
147
148 git merge-base $(cat branches.sorted) >actual &&
149 test_cmp expect actual
150'
151
f2463490
HWN
152test_expect_success 'show branch --reflog=2' '
153 sed "s/^> //" >expect <<-\EOF &&
154 > ! [refs/heads/branch10@{0}] (4 years, 5 months ago) commit: branch10
155 > ! [refs/heads/branch10@{1}] (4 years, 5 months ago) commit: branch10
156 > --
157 > + [refs/heads/branch10@{0}] branch10
158 > ++ [refs/heads/branch10@{1}] initial
159 EOF
160 git show-branch --reflog=2 >actual &&
161 test_cmp actual expect
162'
163
ce567d18 164test_done