Re: [GSOC PATCH 2/2] config: set comment_line_str to "#" when core.commentChar=auto

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

 



Ayush Chandekar <ayu.chandekar@xxxxxxxxx> writes:

> If conflict comments already use a comment character that isn't "#", and
> core.commentChar is set "auto", Git will ignore these lines during the
> scan using ignored_log_message_bytes() and pick a new comment character
> based on the rest of the message. The newly chosen character may be
> different from the one used in the conflict comments and therefore,
> these are no longer treated as comments and end up in the final commit
> message.
>
> For example, during a rebase if the user previously set
> core.commentChar=% and then encounters a conflict, conflict comments
> like "% Conflicts:" are generated. If the user subsequently sets
> core.commentChar=auto before running `rebase --continue`, Git parses the
> "auto" setting and begins scanning. It first uses the existing
> 'comment_line_str' (which is '%') to detect and ignore conflict comments
> via ignored_log_message_bytes().
>
> Then, Git scans the rest of the message (excluding conflict comments),
> sees that none of the remaining lines start with '#' and decides to set
> comment_line_str to '#'. Since the final commit character differs from
> the one used in the conflict comments, those lines are no longer
> considered comments and get included in the final commit message.
>
> Set 'comment_line_str' to '#' when core.commentChar is set to 'auto' to
> reset any previously set value.
>
> While this does not solve the issue of conflict comment inclusion and
> the user visible behaviour stays tha same, it standardizes the behaviour
> of the code by always resetting 'comment_line_str' to '#' when
> core.commentChar=auto is parsed.
>
> Mentored-by: Christian Couder <christian.couder@xxxxxxxxx>
> Mentored-by: Ghanshyam Thakkar <shyamthakkar001@xxxxxxxxx>
> Signed-off-by: Ayush Chandekar <ayu.chandekar@xxxxxxxxx>
> ---
>  config.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
>
> diff --git a/config.c b/config.c
> index eb60c293ab..bb75bdc65d 100644
> --- a/config.c
> +++ b/config.c
> @@ -1537,9 +1537,11 @@ static int git_default_core_config(const char *var, const char *value,
>  	    !strcmp(var, "core.commentstring")) {
>  		if (!value)
>  			return config_error_nonbool(var);
> -		else if (!strcasecmp(value, "auto"))
> +		else if (!strcasecmp(value, "auto")) {
>  			auto_comment_line_char = 1;
> -		else if (value[0]) {
> +			FREE_AND_NULL(comment_line_str_to_free);
> +			comment_line_str = "#";
> +		} else if (value[0]) {
>  			if (strchr(value, '\n'))
>  				return error(_("%s cannot contain newline"), var);
>  			comment_line_str = value;

This patch is exactly what Phillip suggested in

https://lore.kernel.org/git/9e96aaab-79a2-4632-94cd-d016d4a63b30@xxxxxxxxx/

isn't it?  Makes sense to me.





[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