diff mbox series

[v2,2/2] sequencer: fix remaining hardcoded comment char

Message ID c9f4ff34dbdb7ba221e4203bb6551b80948dc71d.1698728953.git.gitgitgadget@gmail.com (mailing list archive)
State New, archived
Headers show
Series sequencer: remove use of hardcoded comment char | expand

Commit Message

Tony Tung Oct. 31, 2023, 5:09 a.m. UTC
From: Tony Tung <tonytung@merly.org>

Signed-off-by: Tony Tung <tonytung@merly.org>
---
 sequencer.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

Comments

Phillip Wood Oct. 31, 2023, 11:27 a.m. UTC | #1
Hi Tony

Thanks for working on this. When you're submitting patches please try 
testing them locally and check the CI before doing '/submit'. In this 
case all the jobs that try to compile git are failing - see 
https://github.com/gitgitgadget/git/actions/runs/6702301267/job/18211090139?pr=1603#step:4:260 
for example.

On 31/10/2023 05:09, Tony Tung via GitGitGadget wrote:
> From: Tony Tung <tonytung@merly.org>
> 
> Signed-off-by: Tony Tung <tonytung@merly.org>
> ---
>   sequencer.c | 18 +++++++++++++-----
>   1 file changed, 13 insertions(+), 5 deletions(-)
> 
> diff --git a/sequencer.c b/sequencer.c
> index 8c6666d5e43..bbadc3fb710 100644
> --- a/sequencer.c
> +++ b/sequencer.c
> @@ -1893,8 +1893,14 @@ static void update_squash_message_for_fixup(struct strbuf *msg)
>   	size_t orig_msg_len;
>   	int i = 1;
>   
> -	strbuf_addf(&buf1, "# %s\n", _(first_commit_msg_str));
> -	strbuf_addf(&buf2, "# %s\n", _(skip_first_commit_msg_str));
> +	strbuf_commented_addf(&buf1,
> +			      comment_line_char,
> +			      "%s\n",
> +			      _(first_commit_msg_str));

This is what is causing the compilation the fail. It should be

	strbuf_commented_addf(&buf1, "%c $s\n", comment_char_line,
			      _(first_commit_msg_str));

> +	strbuf_commented_addf(&buf2,
> +			      comment_line_char,
> +			      "%s\n",
> +			      _(skip_first_commit_msg_str));

This needs changing in the same way.

It would be nice to add a test for this. I think we can do that by adding

	test_config core.commentchar :

To the beginning of the test '--skip after failed fixup cleans commit 
message' in t3418-rebase-continue.sh and changing the expected message 
so that it uses ':' instead of '#' for the comments.

>   	s = start = orig_msg = strbuf_detach(msg, &orig_msg_len);
>   	while (s) {
>   		const char *next;
> @@ -2269,8 +2275,9 @@ static int do_pick_commit(struct repository *r,
>   		next = parent;
>   		next_label = msg.parent_label;
>   		if (opts->commit_use_reference) {
> -			strbuf_addstr(&msgbuf,
> -				"# *** SAY WHY WE ARE REVERTING ON THE TITLE LINE ***");
> +			strbuf_commented_addf(&msgbuf,
> +					      "%s",
> +					      "*** SAY WHY WE ARE REVERTING ON THE TITLE LINE ***");
>   		} else if (skip_prefix(msg.subject, "Revert \"", &orig_subject) &&
>   			   /*
>   			    * We don't touch pre-existing repeated reverts, because
> @@ -6082,7 +6089,8 @@ 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_commented_addf(ctx->buf, comment_line_char,
> +			strbuf_commented_addf(ctx->buf,
> +					      comment_line_char,
>   					      "Ref %s checked out at '%s'\n",
>   					      decoration->name, path);

This hunk is unnecessary - it is just changing the code you added in the 
first patch.

Best Wishes

Phillip
diff mbox series

Patch

diff --git a/sequencer.c b/sequencer.c
index 8c6666d5e43..bbadc3fb710 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -1893,8 +1893,14 @@  static void update_squash_message_for_fixup(struct strbuf *msg)
 	size_t orig_msg_len;
 	int i = 1;
 
-	strbuf_addf(&buf1, "# %s\n", _(first_commit_msg_str));
-	strbuf_addf(&buf2, "# %s\n", _(skip_first_commit_msg_str));
+	strbuf_commented_addf(&buf1,
+			      comment_line_char,
+			      "%s\n",
+			      _(first_commit_msg_str));
+	strbuf_commented_addf(&buf2,
+			      comment_line_char,
+			      "%s\n",
+			      _(skip_first_commit_msg_str));
 	s = start = orig_msg = strbuf_detach(msg, &orig_msg_len);
 	while (s) {
 		const char *next;
@@ -2269,8 +2275,9 @@  static int do_pick_commit(struct repository *r,
 		next = parent;
 		next_label = msg.parent_label;
 		if (opts->commit_use_reference) {
-			strbuf_addstr(&msgbuf,
-				"# *** SAY WHY WE ARE REVERTING ON THE TITLE LINE ***");
+			strbuf_commented_addf(&msgbuf,
+					      "%s",
+					      "*** SAY WHY WE ARE REVERTING ON THE TITLE LINE ***");
 		} else if (skip_prefix(msg.subject, "Revert \"", &orig_subject) &&
 			   /*
 			    * We don't touch pre-existing repeated reverts, because
@@ -6082,7 +6089,8 @@  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_commented_addf(ctx->buf, comment_line_char,
+			strbuf_commented_addf(ctx->buf,
+					      comment_line_char,
 					      "Ref %s checked out at '%s'\n",
 					      decoration->name, path);
 		} else {