From: Junio C Hamano <gitster@pobox.com>
To: "Yoichi NAKAYAMA via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Yoichi NAKAYAMA <yoichi.nakayama@gmail.com>
Subject: Re: [PATCH v2 2/3] submodule: store settings in worktree config when enabled
Date: Tue, 24 Nov 2026 12:14:02 -0800 [thread overview]
Message-ID: <xmqqmrqyoulx.fsf@gitster.g> (raw)
In-Reply-To: <e816484923b0adb741aec4a36eb5b126ba02a31f.1795273853.git.gitgitgadget@gmail.com> (Yoichi NAKAYAMA via GitGitGadget's message of "Sat, 21 Nov 2026 15:10:52 +0000")
"Yoichi NAKAYAMA via GitGitGadget" <gitgitgadget@gmail.com> writes:
> + /* Set active flag for the submodule being initialized */
> if (!is_submodule_active(the_repository, path)) {
> strbuf_addf(&sb, "submodule.%s.active", sub->name);
> - repo_config_set_gently(the_repository, sb.buf, "true");
> + repo_config_set_worktree_gently(the_repository, sb.buf, "true");
> strbuf_reset(&sb);
> }
Mental note. The is_submodule_active() function is designed to take
the path of the submodule, and not the name of the submodule. That
is why we use path and not 'sub->name' here.
A submodule's name may not necessarily match its path (e.g., you may
add a submodule 'sub' when it was at the path 'sub' and its name and
path may be identical, but then you can move 'sub' to 'mod/sub' and
now its path is 'mod/sub' while the name is still 'sub' to preserve
its identity across such a rename in the superproject). We need to
be careful which one is used by which API functions.
> @@ -1673,17 +1668,31 @@ static void deinit_submodule(const char *path, const char *prefix,
> ...
> + if (the_repository->repository_format_worktree_config) {
> + char *key = xstrfmt("submodule.%s.active", sub->name);
> +
> + repo_config_clear(the_repository);
> + if (is_submodule_active(the_repository, sub->name))
> + repo_config_set_worktree_gently(the_repository,
> + key, "false");
This call to is_submodule_active() using 'sub->name' would break when
the name and path of the submodule are different.
It would also be worth covering a submodule whose name differs from its
path in t/t2405-worktree-submodule.sh.
> @@ -386,6 +389,26 @@ static void copy_filtered_worktree_config(const char *worktree_git_dir)
> error(_("failed to unset '%s' in '%s'"),
> "core.worktree", to_file);
>
> + /* unset "submodule.*.gitdir" */
> + for (i = 0; i < cs.list.nr; i++) {
> + const char *var = cs.list.items[i].e->key;
> + const char *subsection, *key;
> + size_t subsection_len;
> +
> + if (!parse_config_key(var, "submodule",
> + &subsection, &subsection_len, &key) &&
> + subsection && !strcmp(key, "gitdir"))
> + string_list_insert(&keys, var);
> + }
> + for_each_string_list_item(item, &keys) {
> + if (repo_config_set_in_file_gently(the_repository,
> + to_file, item->string,
> + NULL, NULL))
> + error(_("failed to unset '%s' in '%s'"),
> + item->string, to_file);
> + }
This code is trying to copy the worktree config, but this removal would
not work if the file happens to have duplicate 'submodule.<name>.gitdir'
entries. Perhaps use repo_config_set_multivar_in_file_gently() with
CONFIG_FLAGS_MULTI_REPLACE as you want to unset all of these?
Do we need to say something about how various 'submodule.<name>.*'
entries this patch touches interact with 'extensions.worktreeConfig' in
the documentation, perhaps in Documentation/config/submodule.adoc or
somewhere around there?
Thanks.
next prev parent reply other threads:[~2026-11-24 20:14 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-12 12:03 [PATCH 0/3] submodule: support worktree-specific configuration Yoichi NAKAYAMA via GitGitGadget
2026-11-12 12:03 ` [PATCH 1/3] submodule: make submodule.<name>.gitdir relative for worktrees Yoichi NAKAYAMA via GitGitGadget
2026-11-14 15:27 ` Yoichi NAKAYAMA
2026-11-14 15:47 ` Yoichi NAKAYAMA
2026-11-12 12:03 ` [PATCH 2/3] submodule: store settings in worktree config when enabled Yoichi NAKAYAMA via GitGitGadget
2026-11-12 12:03 ` [PATCH 3/3] submodule init: copy submodule.<name>.gitdir to config.worktree Yoichi NAKAYAMA via GitGitGadget
2026-11-21 15:10 ` [PATCH v2 0/3] submodule: support worktree-specific configuration Yoichi NAKAYAMA via GitGitGadget
2026-11-21 15:10 ` [PATCH v2 1/3] submodule: make submodule.<name>.gitdir relative for worktrees Yoichi NAKAYAMA via GitGitGadget
2026-11-24 19:44 ` Junio C Hamano
2026-11-27 5:04 ` Yoichi NAKAYAMA
2026-11-27 5:23 ` Junio C Hamano
2026-11-27 6:15 ` Yoichi NAKAYAMA
2026-11-21 15:10 ` [PATCH v2 2/3] submodule: store settings in worktree config when enabled Yoichi NAKAYAMA via GitGitGadget
2026-11-24 20:14 ` Junio C Hamano [this message]
2026-11-27 12:35 ` Yoichi NAKAYAMA
2026-11-21 15:10 ` [PATCH v2 3/3] submodule init: copy submodule.<name>.gitdir to config.worktree Yoichi NAKAYAMA via GitGitGadget
2026-11-24 20:44 ` Junio C Hamano
2026-11-28 0:14 ` Yoichi NAKAYAMA
2026-11-28 22:05 ` [PATCH v3 0/4] submodule: support worktree-specific configuration Yoichi NAKAYAMA via GitGitGadget
2026-11-28 22:05 ` [PATCH v3 1/4] submodule init: make submodule.<name>.gitdir relative for worktrees Yoichi NAKAYAMA via GitGitGadget
2026-11-28 22:05 ` [PATCH v3 2/4] submodule init: resolve symlinks in submodule.<name>.gitdir Yoichi NAKAYAMA via GitGitGadget
2026-11-28 22:05 ` [PATCH v3 3/4] submodule: store settings in worktree config when enabled Yoichi NAKAYAMA via GitGitGadget
2026-11-28 22:05 ` [PATCH v3 4/4] submodule init: copy submodule.<name>.gitdir to config.worktree Yoichi NAKAYAMA via GitGitGadget
2026-11-29 8:32 ` Junio C Hamano
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=xmqqmrqyoulx.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=yoichi.nakayama@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