Re: [GSOC PATCH v3] commit: avoid scanning trailing comments when 'core.commentChar' is "auto"
From: Ayush Chandekar <hidden>
Date: 2025-07-01 18:34:07
On Tue, Jul 1, 2025 at 6:47 PM Phillip Wood [off-list ref] wrote:
Hi Ayush On 30/06/2025 19:25, Ayush Chandekar wrote:quoted
Range-diff with v2: 1: 4e74e7a9a6 ! 1: 693f890a36 commit: avoid scanning trailing comments when 'core.commentChar' is "auto" @@ Commit message The "auto" value for core.commentchar was introduced in the commit 84c9dc2c5a (commit: allow core.commentChar=auto for character auto - selection, 2014-05-17) but did not exhibt this issue at that time. + selection, 2014-05-17) but did not exhibit this issue at that time. The bug was introduced in commit a6c2654f83 (rebase -m: fix --signoff with conflicts, 2024-04-18) where Git started writing conflict comments @@ t/t3418-rebase-continue.sh: test_expect_success 'there is no --no-reschedule-fai ' +test_expect_success 'no change in comment character due to conflicts markers with core.commentChar=auto' ' -+ test_commit base file && + git checkout -b branch-a && -+ test_commit A file && -+ git checkout -b branch-b base && -+ test_commit B file && ++ test_commit A F1 && ++ git checkout -b branch-b HEAD^ && ++ test_commit B F1 && + test_must_fail git rebase branch-a && -+ printf "B\nA\n" >file && -+ git add file && ++ printf "B\nA\n" >F1 && ++ git add F1 && + GIT_EDITOR="cat >actual" git -c core.commentChar=auto rebase --continue && + # Check that "#" is still the comment character. -+ test_grep "^# Changes to be committed:$" actual ++ test_grep "^# Changes to be committed" actual +' + test_orig_head_helper () {The changes here look good but I think we want to update the config parsing as well so that comment_line_str is reset to '#' when core.commentString=auto. We probably want to do that in its own commit. Thanks Phillip
maybe something like this?
--- a/builtin/commit.c
+++ b/builtin/commit.c@@ -912,8 +912,10 @@ static int prepare_to_commit(const char*index_file, const char *prefix,
if (fwrite(sb.buf, 1, sb.len, s->fp) < sb.len)
die_errno(_("could not write commit template"));
- if (auto_comment_line_char)
+ if (auto_comment_line_char){
+ comment_line_str = "#";
adjust_comment_line_char(&sb);
+ }
strbuf_release(&sb);
or we can do it inside the `adjust_comment_line()` function.
Thanks!
Ayush