git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Junio C Hamano <gitster@pobox.com>
Date
May 12, 2026, 06:41 UTC
Message-ID
<xmqq4ikdnn8g.fsf@gitster.g>
In-Reply-To
<20260403-includeif-worktree-v3-0-109ce5782b03@black-desk.cn>

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

Show 27 quoted lines
> 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 <me@black-desk.cn>
> ---
> Changes in v3:
> - Apply Junio's suggestion.
> - Link to v2: https://lore.kernel.org/r/20260402-includeif-worktree-v2-0-36e339b898d7@black-desk.cn
>
> Changes in v2:
>
> - Add missing signed-off-by lines.
> - Link to v1: https://lore.kernel.org/r/20260401-includeif-worktree-v1-0-906db69f2c79@black-desk.cn

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.
Show 15 quoted lines
>
> ---
> 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,
Previous: Chen Linxuan via B4 RelayNext: Patrick Steinhardt
Message 4 of 11 in “config: refactor include_by_gitdir() into include_by_path()”
  1. 1/2 config: refactor include_by_gitdir() into include_by_path()Chen Linxuan via B4 Relay, Apr 3, 2026
  2. 0/2 includeIf: add "worktree" condition for matching working tree pathChen Linxuan via B4 Relay, Apr 3, 2026
  3. 2/2 config: add "worktree" and "worktree/i" includeIf conditionsChen Linxuan via B4 Relay, Apr 3, 2026
  4. Junio C HamanoMay 12, 2026
  5. Patrick SteinhardtMay 12, 2026
  6. Patrick SteinhardtMay 12, 2026
  7. Phillip WoodMay 12, 2026
  8. Junio C HamanoMay 12, 2026
  9. Chen LinxuanMay 13, 2026
  10. Chen LinxuanMay 13, 2026
  11. Patrick SteinhardtMay 13, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.