On Mon, May 15, 2017 at 5:20 PM, Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx> wrote: > 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. > 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);