show-branch tests: add missing tests

Add missing tests for --remotes, --list and --merge-base. These are not exhaustive, but better than the nothing we have now. There were some tests for this command added in f76412ed6db ([PATCH] Add 'git show-branch'., 2005-08-21) has never been properly tested, namely for the --all option in t6432-merge-recursive-space-options.sh, and some of --merge-base and --independent in t6010-merge-base.sh. This fixes a few more blind spots, but there's still a lot of behavior that's not tested for. These new tests show the odd (and possibly unintentional) behavior of --merge-base with one argument, and how its output is the same as "git merge-base" with N bases in this particular case. See the test added in f621a8454d1 (git-merge-base/git-show-branch --merge-base: Documentation and test, 2009-08-05) for a case where the two aren't the same. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Jun 17, 2021 at 12:53 UTC d65aea37d9b3dd64e29aeb0727c6141f264ce24e
1 file changed +61
t/t3202-show-branch.sh
+61
@@ -85,4 +85,65 @@ test_expect_success 'show-branch --color output' '
85 test_cmp expect actual
86 '
87
88 +test_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 +
97 +test_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 +
112 +test_expect_success 'show branch --list' '
113 + git show-branch --list $(cat branches.sorted) >actual &&
114 + test_cmp expect actual
115 +'
116 +
117 +test_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 +
122 +test_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 +
131 +test_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 +
140 +test_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 +
149 test_done