Re: [Patch 2/3] Documentation/config.txt: add worktree includeIf conditionals.
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jul 14, 2021, 17:10 UTC
- Message-ID
- <xmqqczrkyg77.fsf@gitster.g>
- In-Reply-To
- <006b01d778b6$b74b8600$25e29200$@nexbridge.com>
"Randall S. Becker" <rsbecker@nexbridge.com> writes:
Show 7 quoted lines
>>Assuming that I guessed correctly, is this a deliberate design >>decision not to "automatically add ** after a pattern that ends >>with a slash", and if so why? I would have thought that "in the >>worktrees that I create inside /var/tmp/, please enable these >>configuration variables" would be a fairly natural thing to ask, >>and I do not immediately see a reason why we want to apply >>different syntax rules between "gitdir" and "worktree".
> The reason for this comes down to what is in >*the_repository.
Sorry, but I still do not understand.
> Essentially, the_repository->gitdir always has a /path/to/.git > directory with full qualification.
Yes.
> the_repository->worktree does not have /.git added > for obvious reasons, so the /path/to is bare of the trailing >/.
It may be the case, but /path/to/.git does not have trailing slash, either, so I do not see the relevance.
When you say [includeIf "gitdir:/path/"], the "behave as if ** is added after the slash at the end" rule kicks in, and the pattern "/path/**" is used to see if it matches "/path/to/.git" and it does, right? When you say [includeIf "worktree:/path/"], wouldn't the resulting "/path/**" match "/path/to"?
By the way, I think [PATCH 1/3] should turn the body of include_by_gitdir() to a common helper function that
- accepts a path to a directory and a pattern - turns it into a relpath - prepares the pattern with prepare_include_condition_pattern() - do the match include_by_gitdir() does.
and make include_by_gitdir() a very thin wrapper that passes opts->git_dir to that common helper. Then you do not have to copy the entire function to create your new include_by_worktree(); it can be another very thin wrapper that passes the_repository->worktree instead of opts->git_dir to the common helper, as there is no other difference in these two functions.
Thanks.