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

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.
Previous: Randall S. BeckerNext: Randall S. Becker
Message 7 of 9 in “includeIf series for worktrees”
  1. 0/3 includeIf series for worktreesrandall.becker@nexbridge.ca, Jul 12, 2021
  2. 1/3 config.c: add conditional include based on worktree.randall.becker@nexbridge.ca, Jul 12, 2021
  3. Johannes SchindelinJul 13, 2021
  4. 2/3 Documentation/config.txt: add worktree includeIf conditionals.randall.becker@nexbridge.ca, Jul 12, 2021
  5. Junio C HamanoJul 14, 2021
  6. Randall S. BeckerJul 14, 2021
  7. Junio C HamanoJul 14, 2021
  8. Randall S. BeckerJul 14, 2021
  9. 3/3 t1305: add tests for includeIf:worktree.randall.becker@nexbridge.ca, Jul 12, 2021

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.