Git development
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Chen Linxuan via B4 Relay <devnull+me.black-desk.cn@kernel.org>
Cc: git@vger.kernel.org,
	 Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com>,
	 Patrick Steinhardt <ps@pks.im>,  Chen Linxuan <me@black-desk.cn>,
	 Phillip Wood <phillip.wood@dunelm.org.uk>
Subject: Re: [PATCH v6 2/2] config: add "worktree" and "worktree/i" includeIf conditions
Date: Fri, 03 Jul 2026 02:02:58 -0700	[thread overview]
Message-ID: <xmqq1pdkjvi5.fsf@gitster.g> (raw)
In-Reply-To: <20260703-includeif-worktree-v6-2-a13893ad9a7f@black-desk.cn> (Chen Linxuan via's message of "Fri, 03 Jul 2026 11:13:18 +0800")

Chen Linxuan via B4 Relay <devnull+me.black-desk.cn@kernel.org>
writes:

> +`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.

>  	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.

> +# 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.

  reply	other threads:[~2026-07-03  9:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-03  3:13 [PATCH v6 0/2] includeIf: add "worktree" condition for matching working tree path Chen Linxuan via B4 Relay
2026-07-03  3:13 ` [PATCH v6 1/2] config: refactor include_by_gitdir() into include_by_path() Chen Linxuan via B4 Relay
2026-07-03  3:13 ` [PATCH v6 2/2] config: add "worktree" and "worktree/i" includeIf conditions Chen Linxuan via B4 Relay
2026-07-03  9:02   ` Junio C Hamano [this message]
2026-07-03 11:02   ` Patrick Steinhardt
2026-07-06 12:18     ` Chen Linxuan

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=xmqq1pdkjvi5.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=devnull+me.black-desk.cn@kernel.org \
    --cc=git@vger.kernel.org \
    --cc=kristofferhaugsbakk@fastmail.com \
    --cc=me@black-desk.cn \
    --cc=phillip.wood@dunelm.org.uk \
    --cc=ps@pks.im \
    /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