Hi Ayush
On 01/07/2025 19:33, Ayush Chandekar wrote:
On Tue, Jul 1, 2025 at 6:47 PM Phillip Wood <phillip.wood123@xxxxxxxxx> wrote:
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.
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.
We need to do it when we parse the config so that
append_conflicts_comment() uses '#' as the comment char. See the
(whitespace damaged) diff below
Thanks
Phillip
diff --git a/config.c b/config.c
index eb60c293ab3..bb75bdc65d3 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;