git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH/RFC] The new IncludeIf facility doesn't DWIM when the repo is symlinked
@ 2017-05-15 15:20 Ævar Arnfjörð Bjarmason
  2017-05-15 18:30 ` Ævar Arnfjörð Bjarmason
  0 siblings, 1 reply; 5+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2017-05-15 15:20 UTC (permalink / raw)
  To: Nguyễn Thái Ngọc Duy, Git Mailing List

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:

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);

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-05-16  8:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-15 15:20 [PATCH/RFC] The new IncludeIf facility doesn't DWIM when the repo is symlinked Ævar Arnfjörð Bjarmason
2017-05-15 18:30 ` Ævar Arnfjörð Bjarmason
2017-05-15 19:15   ` [PATCH] config: match both symlink & realpath versions in IncludeIf.gitdir:* Ævar Arnfjörð Bjarmason
2017-05-16  1:15     ` Junio C Hamano
2017-05-16  8:28       ` [PATCH v2] " Ævar Arnfjörð Bjarmason

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).