From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>,
"Git Mailing List" <git@vger.kernel.org>
Subject: [PATCH/RFC] The new IncludeIf facility doesn't DWIM when the repo is symlinked
Date: Mon, 15 May 2017 17:20:01 +0200 [thread overview]
Message-ID: <CACBZZX5d25UyGbb6=kPmzk_5-X0GMptN0kX_--aBADsDy-9kWw@mail.gmail.com> (raw)
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);
next reply other threads:[~2017-05-15 15:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-15 15:20 Ævar Arnfjörð Bjarmason [this message]
2017-05-15 18:30 ` [PATCH/RFC] The new IncludeIf facility doesn't DWIM when the repo is symlinked Æ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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CACBZZX5d25UyGbb6=kPmzk_5-X0GMptN0kX_--aBADsDy-9kWw@mail.gmail.com' \
--to=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=pclouds@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).