Subject: Re: [PATCH v3 0/2] includeIf: add "worktree" condition for matching working tree path

From: Junio C Hamano <[email-masked]>
Date: Tue, 12 May 2026 15:41:35 +0900

Chen Linxuan via B4 Relay <[email-masked]>
writes:

> The `includeIf` mechanism already supports matching on the `.git`
> directory path (`gitdir`) and the currently checked out branch
> (`onbranch`).  But in multi-worktree setups the `.git` directory of a
> linked worktree points into the main repository's `.git/worktrees/`
> area, which makes `gitdir` patterns cumbersome when one wants to
> include config based on the working tree's checkout path instead.
>
> Introduce two new condition keywords:
>
>   - `worktree:<pattern>` matches the realpath of the current worktree's
>     working directory against a glob pattern.
>   - `worktree/i:<pattern>` is the case-insensitive variant.
>
> Supported pattern features: glob wildcards, `**/` and `/**`, `~`
> expansion, `./` relative paths, and trailing-`/` prefix matching.
> The condition never matches in a bare repository.
>
> Signed-off-by: Chen Linxuan <[email-masked]>
> ---
> Changes in v3:
> - Apply Junio's suggestion.
> - Link to v2: https://lore.kernel.org/r/[email-masked]
>
> Changes in v2:
>
> - Add missing signed-off-by lines.
> - Link to v1: https://lore.kernel.org/r/[email-masked]

Can we have a volunteer (or two) to review these patches?  The
feature sounds like a worthwhile thing to have, and the code on the
surface looks OK-ish to me, but I am not fully back up to speed and
can use an extra set of eyeballs.

Thanks.

>
> ---
> Chen Linxuan (2):
>       config: refactor include_by_gitdir() into include_by_path()
>       config: add "worktree" and "worktree/i" includeIf conditions
>
>  Documentation/config.adoc | 50 +++++++++++++++++++++++++++++++++++
>  config.c                  | 25 ++++++++++--------
>  t/t1305-config-include.sh | 66 +++++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 130 insertions(+), 11 deletions(-)
> ---
> base-commit: 270e10ad6dda3379ea0da7efd11e4fbf2cd7a325
> change-id: 20260401-includeif-worktree-fcb64950dfba
>
> Best regards,