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

Re: [PATCH/RFC] The new IncludeIf facility doesn't DWIM when the repo is symlinked

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
May 15, 2017, 18:30 UTC
Message-ID
<CACBZZX5nchNUb-V3U8FL9fuhk=3t42Qhz4=Wh9Qk_0C=x85UdQ@mail.gmail.com>
In-Reply-To
<CACBZZX5d25UyGbb6=kPmzk_5-X0GMptN0kX_--aBADsDy-9kWw@mail.gmail.com>

On Mon, May 15, 2017 at 5:20 PM, Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:

Show 10 quoted lines
> I have a ~/git_tree in my homedir that's symlinked to an external
> drive, and doing "gitdir:~/git_tree/" doesn't work, because instead of
> matching against ~/git_tree it's matched against
> /mnt/some-other-storage/.
>
> Here's a WIP patch that makes this work for me, any reason I shouldn't
> finish this up & that we shouldn't be doing this? The doc don't say
> "we'll only match gitdir against the absolute resolved path" or
> anything like that, so until I checked out the implementation I didn't
> realize what was going on:

On closer inspection I can see that this was actually broken in 86f9515708 ("config: resolve symlinks in conditional include's patterns", 2017-04-05), but works in the initial addition of IncludeIf.

Show 36 quoted lines
> diff --git a/config.c b/config.c
> index b4a3205da3..606acaa3f1 100644
> --- a/config.c
> +++ b/config.c
> @@ -214,6 +214,7 @@ static int include_by_gitdir(const struct
> config_options *opts,
>         struct strbuf pattern = STRBUF_INIT;
>         int ret = 0, prefix;
>         const char *git_dir;
> +       int tried_absolute = 0;
>
>         if (opts->git_dir)
>                 git_dir = opts->git_dir;
> @@ -226,6 +227,7 @@ static int include_by_gitdir(const struct
> config_options *opts,
>         strbuf_add(&pattern, cond, cond_len);
>         prefix = prepare_include_condition_pattern(&pattern);
>
> +again:
>         if (prefix < 0)
>                 goto done;
>
> @@ -245,6 +247,12 @@ static int include_by_gitdir(const struct
> config_options *opts,
>         ret = !wildmatch(pattern.buf + prefix, text.buf + prefix,
>                          icase ? WM_CASEFOLD : 0, NULL);
>
> +       if (!ret && !tried_absolute) {
> +               tried_absolute = 1;
> +               strbuf_reset(&text);
> +               strbuf_add_absolute_path(&text, git_dir);
> +               goto again;
> +       }
>  done:
>         strbuf_release(&pattern);
>         strbuf_release(&text);
Previous: Ævar Arnfjörð BjarmasonNext: Ævar Arnfjörð Bjarmason
Message 2 of 5 in “The new IncludeIf facility doesn't DWIM when the repo is symlinked”
  1. The new IncludeIf facility doesn't DWIM when the repo is symlinkedÆvar Arnfjörð Bjarmason, May 15, 2017
  2. Ævar Arnfjörð BjarmasonMay 15, 2017
  3. config: match both symlink & realpath versions in IncludeIf.gitdir:*Ævar Arnfjörð Bjarmason, May 15, 2017
  4. Junio C HamanoMay 16, 2017
  5. config: match both symlink & realpath versions in IncludeIf.gitdir:*Ævar Arnfjörð Bjarmason, May 16, 2017

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.