git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Phillip Wood <phillip.wood123@gmail.com>
To: Tony Tung via GitGitGadget <gitgitgadget@gmail.com>, git@vger.kernel.org
Cc: Elijah Newren <newren@gmail.com>, Tony Tung <tonytung@merly.org>
Subject: Re: [PATCH v2 1/2] sequencer: remove use of comment character
Date: Tue, 31 Oct 2023 11:43:20 +0000	[thread overview]
Message-ID: <e37d2943-3cb3-4cf9-9f69-26fb42bf1027@gmail.com> (raw)
In-Reply-To: <10598a56d64f5c2b4d8d05d7e7b09a18ef254f88.1698728953.git.gitgitgadget@gmail.com>

Hi Tony

On 31/10/2023 05:09, Tony Tung via GitGitGadget wrote:
> From: Tony Tung <tonytung@merly.org>
> 
> Instead of using the hardcoded `# `, use the
> user-defined comment_line_char.  Adds a test
> to prevent regressions.

Well spotted and thanks for fixing this. Normally we wrap the commit 
message at ~72 chars.

> Signed-off-by: Tony Tung <tonytung@merly.org>
> ---
>   sequencer.c                   |  5 +++--
>   t/t3404-rebase-interactive.sh | 39 +++++++++++++++++++++++++++++++++++
>   2 files changed, 42 insertions(+), 2 deletions(-)
> 
> diff --git a/sequencer.c b/sequencer.c
> index d584cac8ed9..8c6666d5e43 100644
> --- a/sequencer.c
> +++ b/sequencer.c
> @@ -6082,8 +6082,9 @@ static int add_decorations_to_list(const struct commit *commit,
>   		/* If the branch is checked out, then leave a comment instead. */
>   		if ((path = branch_checked_out(decoration->name))) {
>   			item->command = TODO_COMMENT;
> -			strbuf_addf(ctx->buf, "# Ref %s checked out at '%s'\n",
> -				    decoration->name, path);
> +			strbuf_commented_addf(ctx->buf, comment_line_char,
> +					      "Ref %s checked out at '%s'\n",
> +					      decoration->name, path);
>   		} else {
>   			struct string_list_item *sti;
>   			item->command = TODO_UPDATE_REF;
> diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
> index 8ea2bf13026..076dca87871 100755
> --- a/t/t3404-rebase-interactive.sh
> +++ b/t/t3404-rebase-interactive.sh
> @@ -1839,6 +1839,45 @@ test_expect_success '--update-refs adds label and update-ref commands' '
>   	)
>   '

Thank you for taking the time to add a test. I think it could be 
simplified though as all we really need to do is check that the expected 
comment is present in the todo list. Something like (untested)

test_expect_success '--update-refs works with core.commentChar' '
	git worktree add new-branch &&
	test_when_finished "git worktree remove new-branch" &&
	test_config core.commentchar : &&
	write_script fake-editor.sh <<-\EOF &&
	grep "^: Ref refs/heads/new-branch checked out at .*new-branch" "$1" &&
	# no need to rebase
	>"$1"
	EOF
	(
		test_set_editor "$(pwd)/fake-editor.sh" &&
		git rebase -i --update-refs HEAD^
	)
'

Best Wishes

Phillip

> +test_expect_success '--update-refs works with core.commentChar' '
> +	git checkout -b update-refs-with-commentchar no-conflict-branch &&
> +	test_config core.commentChar : &&
> +	git branch -f base HEAD~4 &&
> +	git branch -f first HEAD~3 &&
> +	git branch -f second HEAD~3 &&
> +	git branch -f third HEAD~1 &&
> +	git commit --allow-empty --fixup=third &&
> +	git branch -f is-not-reordered &&
> +	git commit --allow-empty --fixup=HEAD~4 &&
> +	git branch -f shared-tip &&
> +	git checkout update-refs &&
> +	(
> +		write_script fake-editor.sh <<-\EOF &&
> +		grep "^[^:]" "$1"
> +		exit 1
> +		EOF
> +		test_set_editor "$(pwd)/fake-editor.sh" &&
> +
> +		cat >expect <<-EOF &&
> +		pick $(git log -1 --format=%h J) J
> +		fixup $(git log -1 --format=%h update-refs) fixup! J : empty
> +		update-ref refs/heads/second
> +		update-ref refs/heads/first
> +		pick $(git log -1 --format=%h K) K
> +		pick $(git log -1 --format=%h L) L
> +		fixup $(git log -1 --format=%h is-not-reordered) fixup! L : empty
> +		update-ref refs/heads/third
> +		pick $(git log -1 --format=%h M) M
> +		update-ref refs/heads/no-conflict-branch
> +		update-ref refs/heads/is-not-reordered
> +		update-ref refs/heads/update-refs-with-commentchar
> +		EOF
> +
> +		test_must_fail git rebase -i --autosquash --update-refs primary shared-tip >todo &&
> +		test_cmp expect todo
> +	)
> +'
> +
>   test_expect_success '--update-refs adds commands with --rebase-merges' '
>   	git checkout -b update-refs-with-merge no-conflict-branch &&
>   	git branch -f base HEAD~4 &&


  reply	other threads:[~2023-10-31 11:43 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-30  3:08 [PATCH] sequencer: remove use of comment character Tony Tung via GitGitGadget
2023-10-30  4:00 ` Junio C Hamano
2023-10-30 17:26   ` Elijah Newren
2023-10-30 23:35     ` Junio C Hamano
2023-10-31  4:42       ` Tony Tung
2023-10-31  4:50       ` Tony Tung
2023-10-31  5:33       ` Junio C Hamano
2023-10-31  6:20         ` Elijah Newren
2023-10-31  5:09 ` [PATCH v2 0/2] sequencer: remove use of hardcoded comment char Tony Tung via GitGitGadget
2023-10-31  5:09   ` [PATCH v2 1/2] sequencer: remove use of comment character Tony Tung via GitGitGadget
2023-10-31 11:43     ` Phillip Wood [this message]
2023-11-01  4:59     ` Junio C Hamano
2023-10-31  5:09   ` [PATCH v2 2/2] sequencer: fix remaining hardcoded comment char Tony Tung via GitGitGadget
2023-10-31 11:27     ` Phillip Wood
2023-10-31  6:55   ` [PATCH v2 0/2] sequencer: remove use of " Elijah Newren
2023-10-31 11:18     ` Phillip Wood
2023-11-01  0:16       ` Junio C Hamano
2023-11-01  0:21       ` Elijah Newren

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=e37d2943-3cb3-4cf9-9f69-26fb42bf1027@gmail.com \
    --to=phillip.wood123@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=newren@gmail.com \
    --cc=phillip.wood@dunelm.org.uk \
    --cc=tonytung@merly.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).