rebase: use correct base for --keep-base when a branch is given
[alt-git.git] / t / t3202-show-branch.sh
blob7a1be73ce8771b851dfc2c7a95d80dece4c2b5cb
1 #!/bin/sh
3 test_description='test show-branch'
5 . ./test-lib.sh
7 # arbitrary reference time: 2009-08-30 19:20:00
8 GIT_TEST_DATE_NOW=1251660000; export GIT_TEST_DATE_NOW
10 test_expect_success 'setup' '
11 test_commit initial &&
12 for i in $(test_seq 1 10)
14 git checkout -b branch$i initial &&
15 test_commit --no-tag branch$i || return 1
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
47 test_expect_success 'show-branch with more than 8 branches' '
48 git show-branch $(cat branches.sorted) >actual &&
49 test_cmp expect actual
52 test_expect_success 'show-branch with showbranch.default' '
53 for branch in $(cat branches.sorted)
55 test_config showbranch.default $branch --add || return 1
56 done &&
57 git show-branch >actual &&
58 test_cmp expect actual
61 test_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
91 test_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
100 test_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
115 test_expect_success 'show branch --list' '
116 git show-branch --list $(cat branches.sorted) >actual &&
117 test_cmp expect actual
120 test_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
125 test_expect_success 'show branch --merge-base with one argument' '
126 for branch in $(cat branches.sorted)
128 git rev-parse $branch >expect &&
129 git show-branch --merge-base $branch >actual &&
130 test_cmp expect actual || return 1
131 done
134 test_expect_success 'show branch --merge-base with two arguments' '
135 for branch in $(cat branches.sorted)
137 git rev-parse initial >expect &&
138 git show-branch --merge-base initial $branch >actual &&
139 test_cmp expect actual || return 1
140 done
143 test_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 &&
148 git merge-base $(cat branches.sorted) >actual &&
149 test_cmp expect actual
152 test_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
160 git show-branch --reflog=2 >actual &&
161 test_cmp actual expect
164 test_done