[GSOC RFC] commit: commentChar=auto bug-fix suggestion

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hey everyone,

This rfc is related to the patch for bug-fix [1] I sent recently.
In few words: When core.commentChar is set to "auto", Git scans the
commit message to pick a comment character that isn't present. If old
conflict comments remain, Git mistakenly reads the comment character
in conflict comments as a part of the commit message and chooses
another, causing the conflict lines to be included in the commit
message. Skipping the trailing comment block during the scan allows
Git to reuse the original character, keeping the final commit message
clean.

So after doing this, Phillip and Junio informed me about another bug
which comes across [2]: If conflict comments already use a character
that isn't "#" (e.g., "% Conflicts:") and core.commentChar=auto is
set, Git will ignore these lines during the scan using
ignored_log_message_bytes()(which uses the comment character used in
the conflict message) and then pick a new comment character based on
the rest of the message. The newly chosen character is different from
the one used in the conflict comments, those lines get no longer
treated as comments and end up in the final commit message.

To make this behavior consistent, as Phillip suggested, we can set
comment_line_str to "#" when core.commentChar=auto. So that even if it
breaks, it breaks consistently.

An alternative approach I thought of is to return early from the
'adjust_comment_line_char()' when ignored_log_message_bytes() finds
conflict markers. This would skip the comment charater detection which
ends up keeping the same comment character as the one in conflict
comments. This fixes the issue, but we end up ignoring the
core.commentchar=auto when we detect conflict comments.

You can check the attempts on my branches [3] & [4].
I'd appreciate thoughts on which approach makes more sense.
Thanks!


[1]: https://lore.kernel.org/git/20250626132233.414789-1-ayu.chandekar@xxxxxxxxx/
[2]: https://lore.kernel.org/git/f39a3285-574a-45c6-9646-04eb175f4770@xxxxxxxxx/
[3]: https://github.com/ayu-ch/git/commits/fix-rebase-commit-9
[4]: https://github.com/ayu-ch/git/commits/fix-rebase-commit-8




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux