Re: [PATCH v6 2/2] config: add "worktree" and "worktree/i" includeIf conditions
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jul 3, 2026, 09:02 UTC
- Message-ID
- <xmqq1pdkjvi5.fsf@gitster.g>
- In-Reply-To
- <20260703-includeif-worktree-v6-2-a13893ad9a7f@black-desk.cn>
Chen Linxuan via B4 Relay <devnull+me.black-desk.cn@kernel.org> writes:
Show 13 quoted lines
> +`worktree`:: > + The data that follows the keyword `worktree` and a colon is used as a > + glob pattern. If the working directory of the current worktree matches > + the pattern, the include condition is met. > ... > +can be set once in a global or system-level configuration file (e.g. > +`~/.config/git/config`) and applies to all repositories at once based on > +their worktree location. > + > +`worktree/i`:: > + This is the same as `worktree` except that matching is done > + case-insensitively (e.g. on case-insensitive file systems) > +
OK. I briefly wondered if
`worktree`::
`worktree/i`::
What follows the keyword `worktree` (or `worktree/i`) and a
colon is used as a glob pattern. If the working directory of
the current worktree matches (with `/i` the match is made
case-insensitively) the pattern, ...is easier for those who looks up 'worktree' to notice (without having to scroll too far to look at the other entry) that there is a case insensitive option available. As the construct used in this patch mimicks how `gitdir` and `gitdir/i` are described, however, I think such a change is better done as a separate topic, long after this patch lands and graduates to the master, to clean up both `gitdir` and `worktree` in the same commit. So let's leave it out of this topic.
Show 8 quoted lines
> else if (skip_prefix_mem(cond, cond_len, "gitdir/i:", &cond, &cond_len)) > return include_by_path(kvi, opts->git_dir, cond, cond_len, 1); > + else if (skip_prefix_mem(cond, cond_len, "worktree:", &cond, &cond_len)) > + return include_by_path(kvi, inc->repo ? repo_get_work_tree(inc->repo) : NULL, > + cond, cond_len, 0); > + else if (skip_prefix_mem(cond, cond_len, "worktree/i:", &cond, &cond_len)) > + return include_by_path(kvi, inc->repo ? repo_get_work_tree(inc->repo) : NULL, > + cond, cond_len, 1);
Fairly straight-forward.
Show 9 quoted lines
> +# Use a loose pattern so the "present in non-worktree cases" check works > +# for Unix-style absolute paths and Windows paths like D:/a/git/... > +test_expect_success 'conditional include, worktree without repository' ' > + test_when_finished "rm -f .gitconfig config.inc" && > + git config set -f .gitconfig "includeIf.worktree:**.path" config.inc && > + git config set -f config.inc foo.bar baz && > + git config get foo.bar && > + test_must_fail nongit git config get foo.bar > +'
This looks much easier to understand than the previous round.
Thanks.