* [PATCH 1/4] show-branch tests: rename the one "show-branch" test file
2021-06-14 17:18 [PATCH 0/4] show-branch: add missing tests, trivial color output fix Ævar Arnfjörð Bjarmason
@ 2021-06-14 17:18 ` Ævar Arnfjörð Bjarmason
2021-06-14 17:18 ` [PATCH 2/4] show-branch tests: modernize test code Ævar Arnfjörð Bjarmason
` (4 subsequent siblings)
5 siblings, 0 replies; 17+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2021-06-14 17:18 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Johannes Schindelin, Michael J Gruber,
Ævar Arnfjörð Bjarmason
Rename the only *show-branch* test file to indicate that more tests
belong it in than just the one-off octopus test it now contains.
The test was initially added in ce567d1867a (Add test to show that
show-branch misses out the 8th column, 2008-07-23) and
11ee57bc4c4 (sort_in_topological_order(): avoid setting a commit flag,
2008-07-23). Those two add almost the same content, one with a
test_expect_success and the other a test_expect_failure (a bug being
tested for was fixed on one of the branches).
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
t/{t3202-show-branch-octopus.sh => t3202-show-branch.sh} | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
rename t/{t3202-show-branch-octopus.sh => t3202-show-branch.sh} (95%)
diff --git a/t/t3202-show-branch-octopus.sh b/t/t3202-show-branch.sh
similarity index 95%
rename from t/t3202-show-branch-octopus.sh
rename to t/t3202-show-branch.sh
index 5cb0126cfed..8cfbbf79c1b 100755
--- a/t/t3202-show-branch-octopus.sh
+++ b/t/t3202-show-branch.sh
@@ -1,6 +1,6 @@
#!/bin/sh
-test_description='test show-branch with more than 8 heads'
+test_description='test show-branch'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
--
2.32.0.555.g0268d380f7b
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 2/4] show-branch tests: modernize test code
2021-06-14 17:18 [PATCH 0/4] show-branch: add missing tests, trivial color output fix Ævar Arnfjörð Bjarmason
2021-06-14 17:18 ` [PATCH 1/4] show-branch tests: rename the one "show-branch" test file Ævar Arnfjörð Bjarmason
@ 2021-06-14 17:18 ` Ævar Arnfjörð Bjarmason
2021-06-14 17:18 ` [PATCH 3/4] show-branch: fix and test --color output Ævar Arnfjörð Bjarmason
` (3 subsequent siblings)
5 siblings, 0 replies; 17+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2021-06-14 17:18 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Johannes Schindelin, Michael J Gruber,
Ævar Arnfjörð Bjarmason
Modernize test code added in ce567d1867a (Add test to show that
show-branch misses out the 8th column, 2008-07-23) and
11ee57bc4c4 (sort_in_topological_order(): avoid setting a commit flag,
2008-07-23) to use test helpers.
I'm renaming "out" to "actual" for consistency with other tests, and
introducing a "branches.sorted" file in the setup, to make it clear
that it's important that the list be sorted in this particular way.
The "show-branch" output is indented with spaces, which would cause
complaints under "git show --check" with an indented here-doc
block. Let's prefix the lines with "> " to work around that, and to
make it clear that the leading whitespace is important.
We can also get rid of the hardcoding of "main" added here in
334afbc76fb (tests: mark tests relying on the current default for
`init.defaultBranch`, 2020-11-18). For this test we're setting up an
"initial" commit anyway, and now that we've moved over to test_commit
we can reference that instead.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
t/t3202-show-branch.sh | 92 ++++++++++++++++++------------------------
1 file changed, 40 insertions(+), 52 deletions(-)
diff --git a/t/t3202-show-branch.sh b/t/t3202-show-branch.sh
index 8cfbbf79c1b..7b06048905a 100755
--- a/t/t3202-show-branch.sh
+++ b/t/t3202-show-branch.sh
@@ -2,69 +2,57 @@
test_description='test show-branch'
-GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
-export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
-
. ./test-lib.sh
-numbers="1 2 3 4 5 6 7 8 9 10"
-
test_expect_success 'setup' '
-
- > file &&
- git add file &&
- test_tick &&
- git commit -m initial &&
-
- for i in $numbers
+ test_commit initial &&
+ for i in $(test_seq 1 10)
do
- git checkout -b branch$i main &&
- > file$i &&
- git add file$i &&
- test_tick &&
- git commit -m branch$i || return 1
- done
-
+ git checkout -b branch$i initial &&
+ test_commit --no-tag branch$i
+ done &&
+ git for-each-ref \
+ --sort=version:refname \
+ --format="%(refname:strip=2)" \
+ "refs/heads/branch*" >branches.sorted &&
+ sed "s/^> //" >expect <<-\EOF
+ > ! [branch1] branch1
+ > ! [branch2] branch2
+ > ! [branch3] branch3
+ > ! [branch4] branch4
+ > ! [branch5] branch5
+ > ! [branch6] branch6
+ > ! [branch7] branch7
+ > ! [branch8] branch8
+ > ! [branch9] branch9
+ > * [branch10] branch10
+ > ----------
+ > * [branch10] branch10
+ > + [branch9] branch9
+ > + [branch8] branch8
+ > + [branch7] branch7
+ > + [branch6] branch6
+ > + [branch5] branch5
+ > + [branch4] branch4
+ > + [branch3] branch3
+ > + [branch2] branch2
+ > + [branch1] branch1
+ > +++++++++* [branch10^] initial
+ EOF
'
-cat > expect << EOF
-! [branch1] branch1
- ! [branch2] branch2
- ! [branch3] branch3
- ! [branch4] branch4
- ! [branch5] branch5
- ! [branch6] branch6
- ! [branch7] branch7
- ! [branch8] branch8
- ! [branch9] branch9
- * [branch10] branch10
-----------
- * [branch10] branch10
- + [branch9] branch9
- + [branch8] branch8
- + [branch7] branch7
- + [branch6] branch6
- + [branch5] branch5
- + [branch4] branch4
- + [branch3] branch3
- + [branch2] branch2
-+ [branch1] branch1
-+++++++++* [branch10^] initial
-EOF
-
test_expect_success 'show-branch with more than 8 branches' '
-
- git show-branch $(for i in $numbers; do echo branch$i; done) > out &&
- test_cmp expect out
-
+ git show-branch $(cat branches.sorted) >actual &&
+ test_cmp expect actual
'
test_expect_success 'show-branch with showbranch.default' '
- for i in $numbers; do
- git config --add showbranch.default branch$i
+ for branch in $(cat branches.sorted)
+ do
+ test_config showbranch.default $branch --add
done &&
- git show-branch >out &&
- test_cmp expect out
+ git show-branch >actual &&
+ test_cmp expect actual
'
test_done
--
2.32.0.555.g0268d380f7b
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 3/4] show-branch: fix and test --color output
2021-06-14 17:18 [PATCH 0/4] show-branch: add missing tests, trivial color output fix Ævar Arnfjörð Bjarmason
2021-06-14 17:18 ` [PATCH 1/4] show-branch tests: rename the one "show-branch" test file Ævar Arnfjörð Bjarmason
2021-06-14 17:18 ` [PATCH 2/4] show-branch tests: modernize test code Ævar Arnfjörð Bjarmason
@ 2021-06-14 17:18 ` Ævar Arnfjörð Bjarmason
2021-06-14 17:18 ` [PATCH 4/4] show-branch tests: add missing tests Ævar Arnfjörð Bjarmason
` (2 subsequent siblings)
5 siblings, 0 replies; 17+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2021-06-14 17:18 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Johannes Schindelin, Michael J Gruber,
Ævar Arnfjörð Bjarmason
Fix the "show-branch --color" output so it doesn't needlessly color
and reset each time it emits a space character.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
builtin/show-branch.c | 9 ++++++---
t/t3202-show-branch.sh | 30 ++++++++++++++++++++++++++++++
2 files changed, 36 insertions(+), 3 deletions(-)
diff --git a/builtin/show-branch.c b/builtin/show-branch.c
index d6d2dabeca8..d77ce7aeb38 100644
--- a/builtin/show-branch.c
+++ b/builtin/show-branch.c
@@ -939,9 +939,12 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
mark = '*';
else
mark = '+';
- printf("%s%c%s",
- get_color_code(i),
- mark, get_color_reset_code());
+ if (mark == ' ')
+ putchar(mark);
+ else
+ printf("%s%c%s",
+ get_color_code(i),
+ mark, get_color_reset_code());
}
putchar(' ');
}
diff --git a/t/t3202-show-branch.sh b/t/t3202-show-branch.sh
index 7b06048905a..54025f03379 100755
--- a/t/t3202-show-branch.sh
+++ b/t/t3202-show-branch.sh
@@ -55,4 +55,34 @@ test_expect_success 'show-branch with showbranch.default' '
test_cmp expect actual
'
+test_expect_success 'show-branch --color output' '
+ sed "s/^> //" >expect <<-\EOF &&
+ > <RED>!<RESET> [branch1] branch1
+ > <GREEN>!<RESET> [branch2] branch2
+ > <YELLOW>!<RESET> [branch3] branch3
+ > <BLUE>!<RESET> [branch4] branch4
+ > <MAGENTA>!<RESET> [branch5] branch5
+ > <CYAN>!<RESET> [branch6] branch6
+ > <BOLD;RED>!<RESET> [branch7] branch7
+ > <BOLD;GREEN>!<RESET> [branch8] branch8
+ > <BOLD;YELLOW>!<RESET> [branch9] branch9
+ > <BOLD;BLUE>*<RESET> [branch10] branch10
+ > ----------
+ > <BOLD;BLUE>*<RESET> [branch10] branch10
+ > <BOLD;YELLOW>+<RESET> [branch9] branch9
+ > <BOLD;GREEN>+<RESET> [branch8] branch8
+ > <BOLD;RED>+<RESET> [branch7] branch7
+ > <CYAN>+<RESET> [branch6] branch6
+ > <MAGENTA>+<RESET> [branch5] branch5
+ > <BLUE>+<RESET> [branch4] branch4
+ > <YELLOW>+<RESET> [branch3] branch3
+ > <GREEN>+<RESET> [branch2] branch2
+ > <RED>+<RESET> [branch1] branch1
+ > <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
+ EOF
+ git show-branch --color=always $(cat branches.sorted) >actual.raw &&
+ test_decode_color <actual.raw >actual &&
+ test_cmp expect actual
+'
+
test_done
--
2.32.0.555.g0268d380f7b
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 4/4] show-branch tests: add missing tests
2021-06-14 17:18 [PATCH 0/4] show-branch: add missing tests, trivial color output fix Ævar Arnfjörð Bjarmason
` (2 preceding siblings ...)
2021-06-14 17:18 ` [PATCH 3/4] show-branch: fix and test --color output Ævar Arnfjörð Bjarmason
@ 2021-06-14 17:18 ` Ævar Arnfjörð Bjarmason
2021-06-15 9:24 ` Michael J Gruber
2021-06-15 3:11 ` [PATCH 0/4] show-branch: add missing tests, trivial color output fix Junio C Hamano
2021-06-17 10:53 ` [PATCH v2 0/4] show-branch: add missing tests, trivial color output change Ævar Arnfjörð Bjarmason
5 siblings, 1 reply; 17+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2021-06-14 17:18 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Johannes Schindelin, Michael J Gruber,
Ævar Arnfjörð Bjarmason
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 add (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>
---
t/t3202-show-branch.sh | 61 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 61 insertions(+)
diff --git a/t/t3202-show-branch.sh b/t/t3202-show-branch.sh
index 54025f03379..ad9902a06b9 100755
--- a/t/t3202-show-branch.sh
+++ b/t/t3202-show-branch.sh
@@ -85,4 +85,65 @@ test_expect_success 'show-branch --color output' '
test_cmp expect actual
'
+test_expect_success 'show branch --remotes' '
+ cat >expect.err <<-\EOF &&
+ No revs to be shown.
+ EOF
+ git show-branch -r 2>actual.err >actual.out &&
+ test_cmp expect.err actual.err &&
+ test_must_be_empty actual.out
+'
+
+test_expect_success 'setup show branch --list' '
+ sed "s/^> //" >expect <<-\EOF
+ > [branch1] branch1
+ > [branch2] branch2
+ > [branch3] branch3
+ > [branch4] branch4
+ > [branch5] branch5
+ > [branch6] branch6
+ > [branch7] branch7
+ > [branch8] branch8
+ > [branch9] branch9
+ > * [branch10] branch10
+ EOF
+'
+
+test_expect_success 'show branch --list' '
+ git show-branch --list $(cat branches.sorted) >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'show branch --list has no --color output' '
+ git show-branch --color=always --list $(cat branches.sorted) >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'show branch --merge-base with one argument' '
+ for branch in $(cat branches.sorted)
+ do
+ git rev-parse $branch >expect &&
+ git show-branch --merge-base $branch >actual &&
+ test_cmp expect actual
+ done
+'
+
+test_expect_success 'show branch --merge-base with two arguments' '
+ for branch in $(cat branches.sorted)
+ do
+ git rev-parse initial >expect &&
+ git show-branch --merge-base initial $branch >actual &&
+ test_cmp expect actual
+ done
+'
+
+test_expect_success 'show branch --merge-base with N arguments' '
+ git rev-parse initial >expect &&
+ git show-branch --merge-base $(cat branches.sorted) >actual &&
+ test_cmp expect actual &&
+
+ git merge-base $(cat branches.sorted) >actual &&
+ test_cmp expect actual
+'
+
test_done
--
2.32.0.555.g0268d380f7b
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH 4/4] show-branch tests: add missing tests
2021-06-14 17:18 ` [PATCH 4/4] show-branch tests: add missing tests Ævar Arnfjörð Bjarmason
@ 2021-06-15 9:24 ` Michael J Gruber
0 siblings, 0 replies; 17+ messages in thread
From: Michael J Gruber @ 2021-06-15 9:24 UTC (permalink / raw)
To: git, Ævar Arnfjörð Bjarmason
Cc: Junio C Hamano, Johannes Schindelin,
Ævar Arnfjörð Bjarmason
Ævar Arnfjörð Bjarmason venit, vidit, dixit 2021-06-14 19:18:10:
> 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 add (and possibly unintentional) behavior of
"odd"
Other than that, I don't think show-branch was broken, so I somehow
contest the phrase "fix" in this series, it's more of a clean-up.
Just to be sure: Users have no way of assigning a color code with
background colors to the columns, which is why omitting
the lookup and reset is correct for a space.
Now, people scripting around show-branch might be bitten by that change
because the number of (unprocessed) characters in the output changes, or
because a control character which they used to "tr" is not there any more.
They should not (script this command), I guess.
> --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>
> ---
> t/t3202-show-branch.sh | 61 ++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 61 insertions(+)
>
> diff --git a/t/t3202-show-branch.sh b/t/t3202-show-branch.sh
> index 54025f03379..ad9902a06b9 100755
> --- a/t/t3202-show-branch.sh
> +++ b/t/t3202-show-branch.sh
> @@ -85,4 +85,65 @@ test_expect_success 'show-branch --color output' '
> test_cmp expect actual
> '
>
> +test_expect_success 'show branch --remotes' '
> + cat >expect.err <<-\EOF &&
> + No revs to be shown.
> + EOF
> + git show-branch -r 2>actual.err >actual.out &&
> + test_cmp expect.err actual.err &&
> + test_must_be_empty actual.out
> +'
> +
> +test_expect_success 'setup show branch --list' '
> + sed "s/^> //" >expect <<-\EOF
> + > [branch1] branch1
> + > [branch2] branch2
> + > [branch3] branch3
> + > [branch4] branch4
> + > [branch5] branch5
> + > [branch6] branch6
> + > [branch7] branch7
> + > [branch8] branch8
> + > [branch9] branch9
> + > * [branch10] branch10
> + EOF
> +'
> +
> +test_expect_success 'show branch --list' '
> + git show-branch --list $(cat branches.sorted) >actual &&
> + test_cmp expect actual
> +'
> +
> +test_expect_success 'show branch --list has no --color output' '
> + git show-branch --color=always --list $(cat branches.sorted) >actual &&
> + test_cmp expect actual
> +'
> +
> +test_expect_success 'show branch --merge-base with one argument' '
> + for branch in $(cat branches.sorted)
> + do
> + git rev-parse $branch >expect &&
> + git show-branch --merge-base $branch >actual &&
> + test_cmp expect actual
> + done
> +'
> +
> +test_expect_success 'show branch --merge-base with two arguments' '
> + for branch in $(cat branches.sorted)
> + do
> + git rev-parse initial >expect &&
> + git show-branch --merge-base initial $branch >actual &&
> + test_cmp expect actual
> + done
> +'
> +
> +test_expect_success 'show branch --merge-base with N arguments' '
> + git rev-parse initial >expect &&
> + git show-branch --merge-base $(cat branches.sorted) >actual &&
> + test_cmp expect actual &&
> +
> + git merge-base $(cat branches.sorted) >actual &&
> + test_cmp expect actual
> +'
> +
> test_done
> --
> 2.32.0.555.g0268d380f7b
>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 0/4] show-branch: add missing tests, trivial color output fix
2021-06-14 17:18 [PATCH 0/4] show-branch: add missing tests, trivial color output fix Ævar Arnfjörð Bjarmason
` (3 preceding siblings ...)
2021-06-14 17:18 ` [PATCH 4/4] show-branch tests: add missing tests Ævar Arnfjörð Bjarmason
@ 2021-06-15 3:11 ` Junio C Hamano
2021-06-17 10:53 ` [PATCH v2 0/4] show-branch: add missing tests, trivial color output change Ævar Arnfjörð Bjarmason
5 siblings, 0 replies; 17+ messages in thread
From: Junio C Hamano @ 2021-06-15 3:11 UTC (permalink / raw)
To: Ævar Arnfjörð Bjarmason
Cc: git, Johannes Schindelin, Michael J Gruber
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
> This is a series I've had lying around for a while, when looking at
> the color output for show-branch I noticed it reset and re-enabled
> color for every single space character.
>
> This fixes that, but mostly fixes the mostly non-existing tests for
> that old command it. It still has big blind spots, but now we have
> fewer blind spots.
I am surprised if there are still users of this command that I wrote
only for my own use and that I no longer use more than once every
two months ;-)
Thanks. Will queue.
>
> Ævar Arnfjörð Bjarmason (4):
> show-branch tests: rename the one "show-branch" test file
> show-branch tests: modernize test code
> show-branch: fix and test --color output
> show-branch tests: add missing tests
>
> builtin/show-branch.c | 9 +-
> t/t3202-show-branch-octopus.sh | 70 ----------------
> t/t3202-show-branch.sh | 149 +++++++++++++++++++++++++++++++++
> 3 files changed, 155 insertions(+), 73 deletions(-)
> delete mode 100755 t/t3202-show-branch-octopus.sh
> create mode 100755 t/t3202-show-branch.sh
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH v2 0/4] show-branch: add missing tests, trivial color output change
2021-06-14 17:18 [PATCH 0/4] show-branch: add missing tests, trivial color output fix Ævar Arnfjörð Bjarmason
` (4 preceding siblings ...)
2021-06-15 3:11 ` [PATCH 0/4] show-branch: add missing tests, trivial color output fix Junio C Hamano
@ 2021-06-17 10:53 ` Ævar Arnfjörð Bjarmason
2021-06-17 10:53 ` [PATCH v2 1/4] show-branch tests: rename the one "show-branch" test file Ævar Arnfjörð Bjarmason
` (4 more replies)
5 siblings, 5 replies; 17+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2021-06-17 10:53 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Johannes Schindelin, Michael J Gruber,
Ævar Arnfjörð Bjarmason
This v2 doesn't change any of the code (see range-diff), but better
explains the change per Michael J Gruber's feedback in
https://lore.kernel.org/git/162374905722.40525.516266574605586007.git@grubix.eu/
There's also a trivial grammar fix, s/add/odd/g.
Ævar Arnfjörð Bjarmason (4):
show-branch tests: rename the one "show-branch" test file
show-branch tests: modernize test code
show-branch: don't <COLOR></RESET> for space characters
show-branch tests: add missing tests
builtin/show-branch.c | 9 +-
t/t3202-show-branch-octopus.sh | 70 ----------------
t/t3202-show-branch.sh | 149 +++++++++++++++++++++++++++++++++
3 files changed, 155 insertions(+), 73 deletions(-)
delete mode 100755 t/t3202-show-branch-octopus.sh
create mode 100755 t/t3202-show-branch.sh
Range-diff against v1:
1: 7b8ac43339 = 1: 7b8ac43339 show-branch tests: rename the one "show-branch" test file
2: 27f94abaed = 2: 27f94abaed show-branch tests: modernize test code
3: 8db7029086 ! 3: 937e728f7f show-branch: fix and test --color output
@@ Metadata
Author: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
## Commit message ##
- show-branch: fix and test --color output
+ show-branch: don't <COLOR></RESET> for space characters
- Fix the "show-branch --color" output so it doesn't needlessly color
- and reset each time it emits a space character.
+ Change the colored output introduced in ab07ba2a24 (show-branch: color
+ the commit status signs, 2009-04-22) to not color and reset each
+ individual space character we use for padding. The intent is to color
+ just the "!", "+" etc. characters.
+
+ This makes the output easier to test, so let's do that now. The test
+ would be much more verbose without a color/reset for each space
+ character. Since the coloring cycles through colors we previously had
+ a "rainbow of space characters".
+
+ In theory this breaks things for anyone who's relying on the exact
+ colored output of show-branch, in practice I'd think anyone parsing it
+ isn't actively turning on the colored output.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
4: c54c6a7b20 ! 4: dde0177235 show-branch tests: add missing tests
@@ Commit message
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 add (and possibly unintentional) behavior of
+ 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:
--
2.32.0.571.gdba276db2c
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH v2 1/4] show-branch tests: rename the one "show-branch" test file
2021-06-17 10:53 ` [PATCH v2 0/4] show-branch: add missing tests, trivial color output change Ævar Arnfjörð Bjarmason
@ 2021-06-17 10:53 ` Ævar Arnfjörð Bjarmason
2021-06-17 21:16 ` Felipe Contreras
2021-06-17 10:53 ` [PATCH v2 2/4] show-branch tests: modernize test code Ævar Arnfjörð Bjarmason
` (3 subsequent siblings)
4 siblings, 1 reply; 17+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2021-06-17 10:53 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Johannes Schindelin, Michael J Gruber,
Ævar Arnfjörð Bjarmason
Rename the only *show-branch* test file to indicate that more tests
belong it in than just the one-off octopus test it now contains.
The test was initially added in ce567d1867a (Add test to show that
show-branch misses out the 8th column, 2008-07-23) and
11ee57bc4c4 (sort_in_topological_order(): avoid setting a commit flag,
2008-07-23). Those two add almost the same content, one with a
test_expect_success and the other a test_expect_failure (a bug being
tested for was fixed on one of the branches).
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
t/{t3202-show-branch-octopus.sh => t3202-show-branch.sh} | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
rename t/{t3202-show-branch-octopus.sh => t3202-show-branch.sh} (95%)
diff --git a/t/t3202-show-branch-octopus.sh b/t/t3202-show-branch.sh
similarity index 95%
rename from t/t3202-show-branch-octopus.sh
rename to t/t3202-show-branch.sh
index 5cb0126cfe..8cfbbf79c1 100755
--- a/t/t3202-show-branch-octopus.sh
+++ b/t/t3202-show-branch.sh
@@ -1,6 +1,6 @@
#!/bin/sh
-test_description='test show-branch with more than 8 heads'
+test_description='test show-branch'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
--
2.32.0.571.gdba276db2c
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v2 2/4] show-branch tests: modernize test code
2021-06-17 10:53 ` [PATCH v2 0/4] show-branch: add missing tests, trivial color output change Ævar Arnfjörð Bjarmason
2021-06-17 10:53 ` [PATCH v2 1/4] show-branch tests: rename the one "show-branch" test file Ævar Arnfjörð Bjarmason
@ 2021-06-17 10:53 ` Ævar Arnfjörð Bjarmason
2021-06-17 21:29 ` Felipe Contreras
2021-06-17 10:53 ` [PATCH v2 3/4] show-branch: don't <COLOR></RESET> for space characters Ævar Arnfjörð Bjarmason
` (2 subsequent siblings)
4 siblings, 1 reply; 17+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2021-06-17 10:53 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Johannes Schindelin, Michael J Gruber,
Ævar Arnfjörð Bjarmason
Modernize test code added in ce567d1867a (Add test to show that
show-branch misses out the 8th column, 2008-07-23) and
11ee57bc4c4 (sort_in_topological_order(): avoid setting a commit flag,
2008-07-23) to use test helpers.
I'm renaming "out" to "actual" for consistency with other tests, and
introducing a "branches.sorted" file in the setup, to make it clear
that it's important that the list be sorted in this particular way.
The "show-branch" output is indented with spaces, which would cause
complaints under "git show --check" with an indented here-doc
block. Let's prefix the lines with "> " to work around that, and to
make it clear that the leading whitespace is important.
We can also get rid of the hardcoding of "main" added here in
334afbc76fb (tests: mark tests relying on the current default for
`init.defaultBranch`, 2020-11-18). For this test we're setting up an
"initial" commit anyway, and now that we've moved over to test_commit
we can reference that instead.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
t/t3202-show-branch.sh | 92 ++++++++++++++++++------------------------
1 file changed, 40 insertions(+), 52 deletions(-)
diff --git a/t/t3202-show-branch.sh b/t/t3202-show-branch.sh
index 8cfbbf79c1..7b06048905 100755
--- a/t/t3202-show-branch.sh
+++ b/t/t3202-show-branch.sh
@@ -2,69 +2,57 @@
test_description='test show-branch'
-GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
-export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
-
. ./test-lib.sh
-numbers="1 2 3 4 5 6 7 8 9 10"
-
test_expect_success 'setup' '
-
- > file &&
- git add file &&
- test_tick &&
- git commit -m initial &&
-
- for i in $numbers
+ test_commit initial &&
+ for i in $(test_seq 1 10)
do
- git checkout -b branch$i main &&
- > file$i &&
- git add file$i &&
- test_tick &&
- git commit -m branch$i || return 1
- done
-
+ git checkout -b branch$i initial &&
+ test_commit --no-tag branch$i
+ done &&
+ git for-each-ref \
+ --sort=version:refname \
+ --format="%(refname:strip=2)" \
+ "refs/heads/branch*" >branches.sorted &&
+ sed "s/^> //" >expect <<-\EOF
+ > ! [branch1] branch1
+ > ! [branch2] branch2
+ > ! [branch3] branch3
+ > ! [branch4] branch4
+ > ! [branch5] branch5
+ > ! [branch6] branch6
+ > ! [branch7] branch7
+ > ! [branch8] branch8
+ > ! [branch9] branch9
+ > * [branch10] branch10
+ > ----------
+ > * [branch10] branch10
+ > + [branch9] branch9
+ > + [branch8] branch8
+ > + [branch7] branch7
+ > + [branch6] branch6
+ > + [branch5] branch5
+ > + [branch4] branch4
+ > + [branch3] branch3
+ > + [branch2] branch2
+ > + [branch1] branch1
+ > +++++++++* [branch10^] initial
+ EOF
'
-cat > expect << EOF
-! [branch1] branch1
- ! [branch2] branch2
- ! [branch3] branch3
- ! [branch4] branch4
- ! [branch5] branch5
- ! [branch6] branch6
- ! [branch7] branch7
- ! [branch8] branch8
- ! [branch9] branch9
- * [branch10] branch10
-----------
- * [branch10] branch10
- + [branch9] branch9
- + [branch8] branch8
- + [branch7] branch7
- + [branch6] branch6
- + [branch5] branch5
- + [branch4] branch4
- + [branch3] branch3
- + [branch2] branch2
-+ [branch1] branch1
-+++++++++* [branch10^] initial
-EOF
-
test_expect_success 'show-branch with more than 8 branches' '
-
- git show-branch $(for i in $numbers; do echo branch$i; done) > out &&
- test_cmp expect out
-
+ git show-branch $(cat branches.sorted) >actual &&
+ test_cmp expect actual
'
test_expect_success 'show-branch with showbranch.default' '
- for i in $numbers; do
- git config --add showbranch.default branch$i
+ for branch in $(cat branches.sorted)
+ do
+ test_config showbranch.default $branch --add
done &&
- git show-branch >out &&
- test_cmp expect out
+ git show-branch >actual &&
+ test_cmp expect actual
'
test_done
--
2.32.0.571.gdba276db2c
^ permalink raw reply related [flat|nested] 17+ messages in thread
* RE: [PATCH v2 2/4] show-branch tests: modernize test code
2021-06-17 10:53 ` [PATCH v2 2/4] show-branch tests: modernize test code Ævar Arnfjörð Bjarmason
@ 2021-06-17 21:29 ` Felipe Contreras
0 siblings, 0 replies; 17+ messages in thread
From: Felipe Contreras @ 2021-06-17 21:29 UTC (permalink / raw)
To: Ævar Arnfjörð Bjarmason, git
Cc: Junio C Hamano, Johannes Schindelin, Michael J Gruber,
Ævar Arnfjörð Bjarmason
Ævar Arnfjörð Bjarmason wrote:
> Modernize test code added in ce567d1867a (Add test to show that
> show-branch misses out the 8th column, 2008-07-23) and
> 11ee57bc4c4 (sort_in_topological_order(): avoid setting a commit flag,
> 2008-07-23) to use test helpers.
>
> I'm renaming "out" to "actual" for consistency with other tests, and
> introducing a "branches.sorted" file in the setup, to make it clear
> that it's important that the list be sorted in this particular way.
That is better.
> The "show-branch" output is indented with spaces, which would cause
> complaints under "git show --check" with an indented here-doc
> block. Let's prefix the lines with "> " to work around that, and to
> make it clear that the leading whitespace is important.
I'm not sure this is an improvement. To me the original code is just
fine. Also, I don't think writing an 'expect' file belong in a setup
step.
Additionally I would do this change in a separate patch.
> We can also get rid of the hardcoding of "main" added here in
> 334afbc76fb (tests: mark tests relying on the current default for
> `init.defaultBranch`, 2020-11-18). For this test we're setting up an
> "initial" commit anyway, and now that we've moved over to test_commit
> we can reference that instead.
That's also good.
All the changes in this patch look good to me, however, they are smashed
together in a way that makes the review harder, I see:
1. Use test_commit
2. Rename out to actual
3. Use >actual instead of > actual
4. Use test_seq instead of $numbers
5. Use branches.sorted instead of branch$i
6. Use test_config instead of git config
7. Use internal sed 's/^ //' instead of outside cat
I'm on-board with 6 out of 7, but if these were done it at least 2
patches, they would be clearer. I in fact would prefer one patch per
change (although maybe squash 3 with 2).
Cheers.
--
Felipe Contreras
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH v2 3/4] show-branch: don't <COLOR></RESET> for space characters
2021-06-17 10:53 ` [PATCH v2 0/4] show-branch: add missing tests, trivial color output change Ævar Arnfjörð Bjarmason
2021-06-17 10:53 ` [PATCH v2 1/4] show-branch tests: rename the one "show-branch" test file Ævar Arnfjörð Bjarmason
2021-06-17 10:53 ` [PATCH v2 2/4] show-branch tests: modernize test code Ævar Arnfjörð Bjarmason
@ 2021-06-17 10:53 ` Ævar Arnfjörð Bjarmason
2021-06-17 21:41 ` Felipe Contreras
2021-06-17 10:53 ` [PATCH v2 4/4] show-branch tests: add missing tests Ævar Arnfjörð Bjarmason
2021-06-17 21:46 ` [PATCH v2 0/4] show-branch: add missing tests, trivial color output change Felipe Contreras
4 siblings, 1 reply; 17+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2021-06-17 10:53 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Johannes Schindelin, Michael J Gruber,
Ævar Arnfjörð Bjarmason
Change the colored output introduced in ab07ba2a24 (show-branch: color
the commit status signs, 2009-04-22) to not color and reset each
individual space character we use for padding. The intent is to color
just the "!", "+" etc. characters.
This makes the output easier to test, so let's do that now. The test
would be much more verbose without a color/reset for each space
character. Since the coloring cycles through colors we previously had
a "rainbow of space characters".
In theory this breaks things for anyone who's relying on the exact
colored output of show-branch, in practice I'd think anyone parsing it
isn't actively turning on the colored output.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
builtin/show-branch.c | 9 ++++++---
t/t3202-show-branch.sh | 30 ++++++++++++++++++++++++++++++
2 files changed, 36 insertions(+), 3 deletions(-)
diff --git a/builtin/show-branch.c b/builtin/show-branch.c
index d6d2dabeca..d77ce7aeb3 100644
--- a/builtin/show-branch.c
+++ b/builtin/show-branch.c
@@ -939,9 +939,12 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
mark = '*';
else
mark = '+';
- printf("%s%c%s",
- get_color_code(i),
- mark, get_color_reset_code());
+ if (mark == ' ')
+ putchar(mark);
+ else
+ printf("%s%c%s",
+ get_color_code(i),
+ mark, get_color_reset_code());
}
putchar(' ');
}
diff --git a/t/t3202-show-branch.sh b/t/t3202-show-branch.sh
index 7b06048905..54025f0337 100755
--- a/t/t3202-show-branch.sh
+++ b/t/t3202-show-branch.sh
@@ -55,4 +55,34 @@ test_expect_success 'show-branch with showbranch.default' '
test_cmp expect actual
'
+test_expect_success 'show-branch --color output' '
+ sed "s/^> //" >expect <<-\EOF &&
+ > <RED>!<RESET> [branch1] branch1
+ > <GREEN>!<RESET> [branch2] branch2
+ > <YELLOW>!<RESET> [branch3] branch3
+ > <BLUE>!<RESET> [branch4] branch4
+ > <MAGENTA>!<RESET> [branch5] branch5
+ > <CYAN>!<RESET> [branch6] branch6
+ > <BOLD;RED>!<RESET> [branch7] branch7
+ > <BOLD;GREEN>!<RESET> [branch8] branch8
+ > <BOLD;YELLOW>!<RESET> [branch9] branch9
+ > <BOLD;BLUE>*<RESET> [branch10] branch10
+ > ----------
+ > <BOLD;BLUE>*<RESET> [branch10] branch10
+ > <BOLD;YELLOW>+<RESET> [branch9] branch9
+ > <BOLD;GREEN>+<RESET> [branch8] branch8
+ > <BOLD;RED>+<RESET> [branch7] branch7
+ > <CYAN>+<RESET> [branch6] branch6
+ > <MAGENTA>+<RESET> [branch5] branch5
+ > <BLUE>+<RESET> [branch4] branch4
+ > <YELLOW>+<RESET> [branch3] branch3
+ > <GREEN>+<RESET> [branch2] branch2
+ > <RED>+<RESET> [branch1] branch1
+ > <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
+ EOF
+ git show-branch --color=always $(cat branches.sorted) >actual.raw &&
+ test_decode_color <actual.raw >actual &&
+ test_cmp expect actual
+'
+
test_done
--
2.32.0.571.gdba276db2c
^ permalink raw reply related [flat|nested] 17+ messages in thread
* RE: [PATCH v2 3/4] show-branch: don't <COLOR></RESET> for space characters
2021-06-17 10:53 ` [PATCH v2 3/4] show-branch: don't <COLOR></RESET> for space characters Ævar Arnfjörð Bjarmason
@ 2021-06-17 21:41 ` Felipe Contreras
0 siblings, 0 replies; 17+ messages in thread
From: Felipe Contreras @ 2021-06-17 21:41 UTC (permalink / raw)
To: Ævar Arnfjörð Bjarmason, git
Cc: Junio C Hamano, Johannes Schindelin, Michael J Gruber,
Ævar Arnfjörð Bjarmason
Ævar Arnfjörð Bjarmason wrote:
> Change the colored output introduced in ab07ba2a24 (show-branch: color
> the commit status signs, 2009-04-22) to not color and reset each
> individual space character we use for padding. The intent is to color
> just the "!", "+" etc. characters.
Obviously a fix, but perhaps show the current behavior:
<RED>+<RESET><GREEN> <RESET><YELLOW> <RESET><BLUE> <RESET><MAGENTA> <RESET><CYAN> <RESET><BOLD;RED> <RESET><BOLD;GREEN> <RESET><BOLD;YELLOW> <RESET><BOLD;BLUE> <RESET> [branch1] branch1
Versus:
<RED>+<RESET> [branch1] branch1
> In theory this breaks things for anyone who's relying on the exact
> colored output of show-branch, in practice I'd think anyone parsing it
> isn't actively turning on the colored output.
Please let's limit our worries to real users. Few people use
`git show-branch`, even less would rely on parsing its bogus output.
> --- a/builtin/show-branch.c
> +++ b/builtin/show-branch.c
> @@ -939,9 +939,12 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
> mark = '*';
> else
> mark = '+';
> - printf("%s%c%s",
> - get_color_code(i),
> - mark, get_color_reset_code());
> + if (mark == ' ')
> + putchar(mark);
> + else
> + printf("%s%c%s",
> + get_color_code(i),
> + mark, get_color_reset_code());
Very simple and obvious improvement.
Cheers.
--
Felipe Contreras
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH v2 4/4] show-branch tests: add missing tests
2021-06-17 10:53 ` [PATCH v2 0/4] show-branch: add missing tests, trivial color output change Ævar Arnfjörð Bjarmason
` (2 preceding siblings ...)
2021-06-17 10:53 ` [PATCH v2 3/4] show-branch: don't <COLOR></RESET> for space characters Ævar Arnfjörð Bjarmason
@ 2021-06-17 10:53 ` Ævar Arnfjörð Bjarmason
2021-06-17 21:44 ` Felipe Contreras
2021-06-17 21:46 ` [PATCH v2 0/4] show-branch: add missing tests, trivial color output change Felipe Contreras
4 siblings, 1 reply; 17+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2021-06-17 10:53 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Johannes Schindelin, Michael J Gruber,
Ævar Arnfjörð Bjarmason
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>
---
t/t3202-show-branch.sh | 61 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 61 insertions(+)
diff --git a/t/t3202-show-branch.sh b/t/t3202-show-branch.sh
index 54025f0337..ad9902a06b 100755
--- a/t/t3202-show-branch.sh
+++ b/t/t3202-show-branch.sh
@@ -85,4 +85,65 @@ test_expect_success 'show-branch --color output' '
test_cmp expect actual
'
+test_expect_success 'show branch --remotes' '
+ cat >expect.err <<-\EOF &&
+ No revs to be shown.
+ EOF
+ git show-branch -r 2>actual.err >actual.out &&
+ test_cmp expect.err actual.err &&
+ test_must_be_empty actual.out
+'
+
+test_expect_success 'setup show branch --list' '
+ sed "s/^> //" >expect <<-\EOF
+ > [branch1] branch1
+ > [branch2] branch2
+ > [branch3] branch3
+ > [branch4] branch4
+ > [branch5] branch5
+ > [branch6] branch6
+ > [branch7] branch7
+ > [branch8] branch8
+ > [branch9] branch9
+ > * [branch10] branch10
+ EOF
+'
+
+test_expect_success 'show branch --list' '
+ git show-branch --list $(cat branches.sorted) >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'show branch --list has no --color output' '
+ git show-branch --color=always --list $(cat branches.sorted) >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'show branch --merge-base with one argument' '
+ for branch in $(cat branches.sorted)
+ do
+ git rev-parse $branch >expect &&
+ git show-branch --merge-base $branch >actual &&
+ test_cmp expect actual
+ done
+'
+
+test_expect_success 'show branch --merge-base with two arguments' '
+ for branch in $(cat branches.sorted)
+ do
+ git rev-parse initial >expect &&
+ git show-branch --merge-base initial $branch >actual &&
+ test_cmp expect actual
+ done
+'
+
+test_expect_success 'show branch --merge-base with N arguments' '
+ git rev-parse initial >expect &&
+ git show-branch --merge-base $(cat branches.sorted) >actual &&
+ test_cmp expect actual &&
+
+ git merge-base $(cat branches.sorted) >actual &&
+ test_cmp expect actual
+'
+
test_done
--
2.32.0.571.gdba276db2c
^ permalink raw reply related [flat|nested] 17+ messages in thread
* RE: [PATCH v2 4/4] show-branch tests: add missing tests
2021-06-17 10:53 ` [PATCH v2 4/4] show-branch tests: add missing tests Ævar Arnfjörð Bjarmason
@ 2021-06-17 21:44 ` Felipe Contreras
0 siblings, 0 replies; 17+ messages in thread
From: Felipe Contreras @ 2021-06-17 21:44 UTC (permalink / raw)
To: Ævar Arnfjörð Bjarmason, git
Cc: Junio C Hamano, Johannes Schindelin, Michael J Gruber,
Ævar Arnfjörð Bjarmason
Ævar Arnfjörð Bjarmason wrote:
> Add missing tests for --remotes, --list and --merge-base. These are
> not exhaustive, but better than the nothing we have now.
Indeed, this is better.
> --- a/t/t3202-show-branch.sh
> +++ b/t/t3202-show-branch.sh
> @@ -85,4 +85,65 @@ test_expect_success 'show-branch --color output' '
> test_cmp expect actual
> '
>
> +test_expect_success 'show branch --remotes' '
> + cat >expect.err <<-\EOF &&
> + No revs to be shown.
> + EOF
> + git show-branch -r 2>actual.err >actual.out &&
> + test_cmp expect.err actual.err &&
> + test_must_be_empty actual.out
> +'
> +
> +test_expect_success 'setup show branch --list' '
> + sed "s/^> //" >expect <<-\EOF
> + > [branch1] branch1
> + > [branch2] branch2
> + > [branch3] branch3
> + > [branch4] branch4
> + > [branch5] branch5
> + > [branch6] branch6
> + > [branch7] branch7
> + > [branch8] branch8
> + > [branch9] branch9
> + > * [branch10] branch10
> + EOF
> +'
> +
> +test_expect_success 'show branch --list' '
> + git show-branch --list $(cat branches.sorted) >actual &&
> + test_cmp expect actual
> +'
> +
> +test_expect_success 'show branch --list has no --color output' '
> + git show-branch --color=always --list $(cat branches.sorted) >actual &&
> + test_cmp expect actual
> +'
> +
> +test_expect_success 'show branch --merge-base with one argument' '
> + for branch in $(cat branches.sorted)
> + do
> + git rev-parse $branch >expect &&
> + git show-branch --merge-base $branch >actual &&
> + test_cmp expect actual
> + done
> +'
> +
> +test_expect_success 'show branch --merge-base with two arguments' '
> + for branch in $(cat branches.sorted)
> + do
> + git rev-parse initial >expect &&
> + git show-branch --merge-base initial $branch >actual &&
> + test_cmp expect actual
> + done
> +'
> +
> +test_expect_success 'show branch --merge-base with N arguments' '
> + git rev-parse initial >expect &&
> + git show-branch --merge-base $(cat branches.sorted) >actual &&
> + test_cmp expect actual &&
> +
> + git merge-base $(cat branches.sorted) >actual &&
> + test_cmp expect actual
> +'
> +
> test_done
All these look good to me.
Cheers.
--
Felipe Contreras
^ permalink raw reply [flat|nested] 17+ messages in thread
* RE: [PATCH v2 0/4] show-branch: add missing tests, trivial color output change
2021-06-17 10:53 ` [PATCH v2 0/4] show-branch: add missing tests, trivial color output change Ævar Arnfjörð Bjarmason
` (3 preceding siblings ...)
2021-06-17 10:53 ` [PATCH v2 4/4] show-branch tests: add missing tests Ævar Arnfjörð Bjarmason
@ 2021-06-17 21:46 ` Felipe Contreras
4 siblings, 0 replies; 17+ messages in thread
From: Felipe Contreras @ 2021-06-17 21:46 UTC (permalink / raw)
To: Ævar Arnfjörð Bjarmason, git
Cc: Junio C Hamano, Johannes Schindelin, Michael J Gruber,
Ævar Arnfjörð Bjarmason
Ævar Arnfjörð Bjarmason wrote:
> This v2 doesn't change any of the code (see range-diff), but better
> explains the change per Michael J Gruber's feedback in
> https://lore.kernel.org/git/162374905722.40525.516266574605586007.git@grubix.eu/
>
> There's also a trivial grammar fix, s/add/odd/g.
>
> Ævar Arnfjörð Bjarmason (4):
> show-branch tests: rename the one "show-branch" test file
> show-branch tests: modernize test code
> show-branch: don't <COLOR></RESET> for space characters
> show-branch tests: add missing tests
All these look good to me (I would prefer patch #2 to be split into
multiple patches, but that's not a deal-breaker).
Reviewed-by: Felipe Contreras <felipe.contreras@gmail.com>
--
Felipe Contreras
^ permalink raw reply [flat|nested] 17+ messages in thread