From: Junio C Hamano <gitster@pobox.com>
To: Phillip Wood <phillip.wood123@gmail.com>
Cc: git@vger.kernel.org, Jeff King <peff@peff.net>
Subject: Re: [PATCH] config: remove unneeded struct field
Date: Thu, 17 Jul 2025 10:31:32 -0700 [thread overview]
Message-ID: <xmqqv7nq67wr.fsf@gitster.g> (raw)
In-Reply-To: <31724ce432b19088b7c7643654788d8e712b3193.1752588042.git.phillip.wood@dunelm.org.uk> (Phillip Wood's message of "Tue, 15 Jul 2025 15:00:56 +0100")
Phillip Wood <phillip.wood123@gmail.com> writes:
> I stumbled across this use-after-free while working on the deprecation
> of core.commentChar=auto.
And that other topic also adds more uses of "is kvi->path set?", so
we'd need a bit of semantic conflict resolution, which was fun ;-)
FYI, here is what I'd be using as merge-fix, a change that would be
squashed in when the named branch is merged in.
I expect that this part would change a lot anyway, to make it fail
when "auto" is used under WITH_BREAKING_CHANGES, so the conflict
resolution for the current/previous round may not matter all that
much.
--- >8 ---
Subject: [PATCH] merge-fix/pw/3.0-commentchar-auto-deprecation
Conflicts with pw/config-kvi-remove-path that removes kvi->path
field. Checking if kvi->path is set should be done by inspecting
kvi->origin_type and seeing if it is CONFIG_ORIGIN_FILE instead, and
otherwise kvi->filename is usable when it is CONFIG_ORIGIN_FILE.
---
builtin/commit.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/builtin/commit.c b/builtin/commit.c
index a513709a51..04440fbd3f 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -771,10 +771,10 @@ static int comment_char_config_cb(const char *key, const char *value,
return 0;
cfg->last_key_id = key_id;
- if (!kvi->path) {
+ if (kvi->origin_type != CONFIG_ORIGIN_FILE) {
return 0;
- } else if (get_comment_key_flags(cfg, kvi->path, key_id)) {
- set_comment_key_flags(cfg, kvi->path, key_id, KEY_SEEN_TWICE);
+ } else if (get_comment_key_flags(cfg, kvi->filename, key_id)) {
+ set_comment_key_flags(cfg, kvi->filename, key_id, KEY_SEEN_TWICE);
} else {
struct comment_char_cfg_item *item;
@@ -782,8 +782,8 @@ static int comment_char_config_cb(const char *key, const char *value,
item = &cfg->item[cfg->nr - 1];
item->key_id = key_id;
item->scope = kvi->scope;
- item->path = xstrdup(kvi->path);
- set_comment_key_flags(cfg, kvi->path, key_id, KEY_SEEN_ONCE);
+ item->path = xstrdup(kvi->filename);
+ set_comment_key_flags(cfg, kvi->filename, key_id, KEY_SEEN_ONCE);
}
cfg->auto_set_in_file = value && !strcmp(value, "auto");
--
2.50.1-441-gd7f68e2bd5
next prev parent reply other threads:[~2025-07-17 17:31 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-15 14:00 [PATCH] config: remove unneeded struct field Phillip Wood
2025-07-16 4:34 ` Jeff King
2025-07-16 9:41 ` Phillip Wood
2025-07-17 17:31 ` Junio C Hamano [this message]
2025-07-18 14:40 ` Phillip Wood
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqv7nq67wr.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
--cc=phillip.wood123@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).