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