All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: Derrick Stolee via GitGitGadget <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, gitster@pobox.com, me@ttaylorr.com,
	vdye@github.com, steadmon@google.com,
	Derrick Stolee <derrickstolee@github.com>
Subject: Re: [PATCH v2 02/10] t4207: test coloring of grafted decorations
Date: Wed, 03 Aug 2022 08:25:30 +0200	[thread overview]
Message-ID: <220803.86y1w5g7r0.gmgdl@evledraar.gmail.com> (raw)
In-Reply-To: <b5eb110958baa80b72a345b3c850f1dfceabf076.1659122979.git.gitgitgadget@gmail.com>


On Fri, Jul 29 2022, Derrick Stolee via GitGitGadget wrote:

> From: Derrick Stolee <derrickstolee@github.com>
>
> The color.decorate.<slot> config option added the 'grafted' slot in
> 09c4ba410b0f (log-tree: allow to customize 'grafted' color, 2018-05-26)
> but included no tests for this behavior. When modifying some logic
> around decorations, this ref namespace was ignored and could have been
> lost as a default namespace for 'git log' decorations by default.
>
> Add two tests to t4207 that check that the replaced objects are
> correctly decorated. Use "black" as the color since it is distinct from
> the other colors already in the test. The first test uses regular
> replace-objects while the second creates a commit graft.
>
> Be sure to test both modes with GIT_REPLACE_REF_BASE unset and set to an
> alternative base.
>
> Signed-off-by: Derrick Stolee <derrickstolee@github.com>
> ---
>  t/t4207-log-decoration-colors.sh | 59 ++++++++++++++++++++++++++++++++
>  1 file changed, 59 insertions(+)
>
> diff --git a/t/t4207-log-decoration-colors.sh b/t/t4207-log-decoration-colors.sh
> index 36ac6aff1e4..69f8ac602d6 100755
> --- a/t/t4207-log-decoration-colors.sh
> +++ b/t/t4207-log-decoration-colors.sh
> @@ -18,6 +18,7 @@ test_expect_success setup '
>  	git config color.decorate.tag "reverse bold yellow" &&
>  	git config color.decorate.stash magenta &&
>  	git config color.decorate.HEAD cyan &&
> +	git config color.decorate.grafted black &&
>  
>  	c_reset="<RESET>" &&
>  
> @@ -27,6 +28,7 @@ test_expect_success setup '
>  	c_tag="<BOLD;REVERSE;YELLOW>" &&
>  	c_stash="<MAGENTA>" &&
>  	c_HEAD="<CYAN>" &&
> +	c_grafted="<BLACK>" &&
>  
>  	test_commit A &&
>  	git clone . other &&
> @@ -63,4 +65,61 @@ test_expect_success 'Commit Decorations Colored Correctly' '
>  	test_cmp expected out
>  '
>  
> +cat >expected <<EOF
> +${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_HEAD}HEAD ->\
> + ${c_reset}${c_branch}main${c_reset}${c_commit},\
> + ${c_reset}${c_tag}tag: D${c_reset}${c_commit})${c_reset} D
> +${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_tag}tag: C${c_reset}${c_commit},\
> + ${c_reset}${c_grafted}replaced${c_reset}${c_commit})${c_reset} B
> +${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_tag}tag: A${c_reset}${c_commit})${c_reset} A
> +EOF

I see this is used by (one) existing test, but for new test code let's
add such setup in the test_expect_success block.

A small issue, but e.g. if the partition our trash directories is on
fills up this sort of thing outside of test_expect_success hides the
source of the "first" error.

More generally (just eyeballing this v.s. the existing one) maybe we can
combine them a bit & share some of these lines?

> +test_expect_success 'test coloring with replace-objects' '
> +	test_when_finished rm -rf .git/refs/replace* &&
> +	test_commit C &&
> +	test_commit D &&
> +
> +	git replace HEAD~1 HEAD~2 &&
> +	git log --first-parent --abbrev=10 --decorate --oneline --color=always HEAD |

This hides segfaults, abort() etc. in git log, let's use an intermediate
file rather than git on the LHS of a pipe.

> +	sed "s/[0-9a-f]\{10,10\}/COMMIT_ID/" |

{10,10} in a regex is just {10}, no?

> +	test_decode_color >out &&
> +	test_cmp expected out &&
> +	git replace -d HEAD~1 &&
> +
> +	GIT_REPLACE_REF_BASE=refs/replace2/ git replace HEAD~1 HEAD~2 &&
> +	GIT_REPLACE_REF_BASE=refs/replace2/ git log --first-parent --abbrev=10 \
> +		--decorate --oneline --color=always HEAD |

Ditto LHS.

> +	sed "s/[0-9a-f]\{10,10\}/COMMIT_ID/" |

Ditto RX, but at this point I see it's copy/pasted from the existing
test in the file, might be worth starting by factoring the duplicate
bits out into a function...

> +	test_decode_color >out &&
> +	test_cmp expected out
> +'
> +
> +cat >expected <<EOF
> +${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_HEAD}HEAD ->\
> + ${c_reset}${c_branch}main${c_reset}${c_commit},\
> + ${c_reset}${c_tag}tag: D${c_reset}${c_commit},\
> + ${c_reset}${c_grafted}replaced${c_reset}${c_commit})${c_reset} D
> +${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_tag}tag: v1.0${c_reset}${c_commit},\
> + ${c_reset}${c_tag}tag: B${c_reset}${c_commit})${c_reset} B
> +${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_tag}tag: A${c_reset}${c_commit})${c_reset} A
> +EOF
> +
> +test_expect_success 'test coloring with grafted commit' '
> +	test_when_finished rm -rf .git/refs/replace* &&
> +
> +	git replace --graft HEAD HEAD~2 &&
> +	git log --first-parent --abbrev=10 --decorate --oneline --color=always HEAD |
> +	sed "s/[0-9a-f]\{10,10\}/COMMIT_ID/" |
> +	test_decode_color >out &&
> +	test_cmp expected out &&
> +	git replace -d HEAD &&
> +
> +	GIT_REPLACE_REF_BASE=refs/replace2/ git replace --graft HEAD HEAD~2 &&
> +	GIT_REPLACE_REF_BASE=refs/replace2/ git log --first-parent --abbrev=10 \
> +		--decorate --oneline --color=always HEAD |
> +	sed "s/[0-9a-f]\{10,10\}/COMMIT_ID/" |
> +	test_decode_color >out &&
> +	test_cmp expected out
> +'
> +
>  test_done

...as we had one of these, and now have 3x...

  reply	other threads:[~2022-08-03  6:29 UTC|newest]

Thread overview: 79+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-26 14:04 [PATCH 0/3] log: create tighter default decoration filter Derrick Stolee via GitGitGadget
2022-07-26 14:04 ` [PATCH 1/3] refs: allow "HEAD" as " Derrick Stolee via GitGitGadget
2022-07-26 15:10   ` Ævar Arnfjörð Bjarmason
2022-07-29 13:23     ` Derrick Stolee
2022-07-26 14:04 ` [PATCH 2/3] log: add default " Derrick Stolee via GitGitGadget
2022-07-26 14:39   ` Ævar Arnfjörð Bjarmason
2022-07-29 13:25     ` Derrick Stolee
2022-07-26 15:04   ` Ævar Arnfjörð Bjarmason
2022-07-27 14:50   ` Junio C Hamano
2022-07-27 19:07     ` Derrick Stolee
2022-07-27 19:38       ` Junio C Hamano
2022-07-29 20:32     ` Jeff King
2022-07-26 14:04 ` [PATCH 3/3] maintenance: stop writing log.excludeDecoration Derrick Stolee via GitGitGadget
2022-07-27 14:50   ` Junio C Hamano
2022-07-26 14:44 ` [PATCH 0/3] log: create tighter default decoration filter Ævar Arnfjörð Bjarmason
2022-07-26 16:38   ` Derrick Stolee
2022-07-26 18:19     ` Ævar Arnfjörð Bjarmason
2022-07-27 13:41       ` Derrick Stolee
2022-07-27 20:40         ` Ævar Arnfjörð Bjarmason
2022-07-29 19:29 ` [PATCH v2 00/10] " Derrick Stolee via GitGitGadget
2022-07-29 19:29   ` [PATCH v2 01/10] refs: allow "HEAD" as " Derrick Stolee via GitGitGadget
2022-08-03  6:03     ` Junio C Hamano
2022-08-04 13:22       ` Derrick Stolee
2022-07-29 19:29   ` [PATCH v2 02/10] t4207: test coloring of grafted decorations Derrick Stolee via GitGitGadget
2022-08-03  6:25     ` Ævar Arnfjörð Bjarmason [this message]
2022-08-03  6:44       ` Eric Sunshine
2022-08-03 13:03         ` Ævar Arnfjörð Bjarmason
2022-08-04  4:05           ` Eric Sunshine
2022-08-04 17:23             ` Junio C Hamano
2022-08-05 14:21               ` Derrick Stolee
2022-07-29 19:29   ` [PATCH v2 03/10] refs: add array of ref namespaces Derrick Stolee via GitGitGadget
2022-08-03  6:16     ` Junio C Hamano
2022-08-04 13:29       ` Derrick Stolee
2022-08-04 16:16         ` Junio C Hamano
2022-08-03 22:39     ` Josh Steadmon
2022-08-04 13:29       ` Derrick Stolee
2022-07-29 19:29   ` [PATCH v2 04/10] refs: use ref_namespaces for replace refs base Derrick Stolee via GitGitGadget
2022-08-03 22:38     ` Josh Steadmon
2022-08-04 13:30       ` Derrick Stolee
2022-07-29 19:29   ` [PATCH v2 05/10] log-tree: use ref_namespaces instead of if/else-if Derrick Stolee via GitGitGadget
2022-08-03  6:31     ` Junio C Hamano
2022-08-04 13:31       ` Derrick Stolee
2022-08-04 14:34         ` Derrick Stolee
2022-08-04 14:50           ` Derrick Stolee
2022-08-04 17:40             ` Junio C Hamano
2022-08-04 20:17               ` Derrick Stolee
2022-07-29 19:29   ` [PATCH v2 06/10] log: add default decoration filter Derrick Stolee via GitGitGadget
2022-08-04  7:08     ` Ævar Arnfjörð Bjarmason
2022-08-05 14:27       ` Derrick Stolee
2022-08-05 14:50         ` Ævar Arnfjörð Bjarmason
2022-08-05 15:09           ` Derrick Stolee
2022-08-11 19:30             ` Ævar Arnfjörð Bjarmason
2022-08-12 19:37               ` Derrick Stolee
2022-07-29 19:29   ` [PATCH v2 07/10] log: add --decorate-all option Derrick Stolee via GitGitGadget
2022-08-04 16:57     ` Junio C Hamano
2022-07-29 19:29   ` [PATCH v2 08/10] log: create log.decorateFilter=all Derrick Stolee via GitGitGadget
2022-08-03 22:42     ` Josh Steadmon
2022-08-04 13:38       ` Derrick Stolee
2022-07-29 19:29   ` [PATCH v2 09/10] maintenance: stop writing log.excludeDecoration Derrick Stolee via GitGitGadget
2022-08-03  6:36     ` Junio C Hamano
2022-07-29 19:29   ` [PATCH v2 10/10] fetch: use ref_namespaces during prefetch Derrick Stolee via GitGitGadget
2022-08-05 17:58   ` [PATCH v3 00/11] log: create tighter default decoration filter Derrick Stolee via GitGitGadget
2022-08-05 17:58     ` [PATCH v3 01/11] refs: allow "HEAD" as " Derrick Stolee via GitGitGadget
2022-08-05 17:58     ` [PATCH v3 02/11] t4207: modernize test Derrick Stolee via GitGitGadget
2022-08-05 17:58     ` [PATCH v3 03/11] t4207: test coloring of grafted decorations Derrick Stolee via GitGitGadget
2022-08-05 17:58     ` [PATCH v3 04/11] refs: add array of ref namespaces Derrick Stolee via GitGitGadget
2022-08-05 17:58     ` [PATCH v3 05/11] refs: use ref_namespaces for replace refs base Derrick Stolee via GitGitGadget
2022-08-05 17:58     ` [PATCH v3 06/11] log-tree: use ref_namespaces instead of if/else-if Derrick Stolee via GitGitGadget
2022-08-05 17:58     ` [PATCH v3 07/11] log: add default decoration filter Derrick Stolee via GitGitGadget
2022-09-08 21:13       ` Glen Choo
2022-09-09 12:23         ` Derrick Stolee
2022-09-09 16:19           ` Junio C Hamano
2022-09-09 16:40             ` Derrick Stolee
2022-09-09 17:41               ` Junio C Hamano
2022-09-09 17:12             ` Glen Choo
2022-08-05 17:58     ` [PATCH v3 08/11] log: add --clear-decorations option Derrick Stolee via GitGitGadget
2022-08-05 17:58     ` [PATCH v3 09/11] log: create log.initialDecorationSet=all Derrick Stolee via GitGitGadget
2022-08-05 17:58     ` [PATCH v3 10/11] maintenance: stop writing log.excludeDecoration Derrick Stolee via GitGitGadget
2022-08-05 17:58     ` [PATCH v3 11/11] fetch: use ref_namespaces during prefetch Derrick Stolee via GitGitGadget

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=220803.86y1w5g7r0.gmgdl@evledraar.gmail.com \
    --to=avarab@gmail.com \
    --cc=derrickstolee@github.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=gitster@pobox.com \
    --cc=me@ttaylorr.com \
    --cc=steadmon@google.com \
    --cc=vdye@github.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.