3 test_description
='test show-branch'
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
18 --sort=version:refname \
19 --format="%(refname:strip=2)" \
20 "refs/heads/branch*" >branches.sorted &&
21 sed "s/^> //" >expect <<-\EOF
31 > * [branch10] branch10
33 > * [branch10] branch10
43 > +++++++++* [branch10^] initial
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
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
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
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 &&
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
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
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
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
157 > + [refs/heads/branch10@{0}] branch10
158 > ++ [refs/heads/branch10@{1}] initial
160 git show-branch --reflog=2 >actual &&
161 test_cmp actual expect