Git Mailing List Archive mirror
 help / color / mirror / Atom feed
From: "brian m. carlson" <sandals@crustytoothpaste.net>
To: Simon Thurston <simongethurston@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [Bug Report] git config includeIf not traversing symlink subdirectories
Date: Fri, 3 May 2024 23:06:14 +0000	[thread overview]
Message-ID: <ZjVt5jtC8cKgWpqQ@tapette.crustytoothpaste.net> (raw)
In-Reply-To: <CAKx51amU_c9EU+573RWDc0+w3V2u5TSk+mQhts1gYyKRhxGCzQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2662 bytes --]

On 2024-05-03 at 21:31:59, Simon Thurston wrote:
> Thank you for filling out a Git bug report!
> Please answer the following questions to help us understand your issue.
> 
> What did you do before the bug happened? (Steps to reproduce your issue)
> On Windows. Create a directory. Configre a gitconfig file to includeIf
> gitdir that directory. Add any configuration you wish to the gitconfig
> file pointed to by the includeif path. Inside the created directory,
> create a symlink to a UNC Path/Network location. Change directory into
> the symlinked directory. Run git config --show-origin on a configured
> value.

I've included a shell script below that tries to provide a testcase for
your reproduction steps.  Since I'm on Linux, I don't have a UNC drive,
but I created a different location outside of the repository called
other-dir that simulates the same behaviour:

----
#!/bin/sh

tempdir=$(mktemp -d)
cd "$tempdir"
cat >config <<EOM
[includeIf "gitdir:$tempdir/dir/"]
    path = "$tempdir/other-config"
EOM
cat >other-config <<EOM
[user]
    name = "Foo Bar"
EOM

export GIT_CONFIG_GLOBAL="$tempdir/config"
mkdir "$tempdir/dir"
mkdir "$tempdir/other-dir"
cd "$tempdir/dir"
git init -b dev
echo "In dir ($PWD):"
git config -l --show-origin
ln -s ../other-dir other-dir
cd other-dir
echo "In symlink ($PWD):"
git config -l --show-origin
----

> What did you expect to happen? (Expected behavior)
> The value configured in the includeIf path to be found.
> 
> What happened instead? (Actual behavior)
> No configuration data found.
> 
> What's different between what you expected and what actually happened?
> Git seems to be unable to traverse subdirectories that are symlinks to
> include any git repositories stored inside them.

Assuming my reproduction steps are correct, this is expected.  Git
always determines the Git directory by resolving it to an absolute path
containing no symlinks with the equivalent of `realpath` on Linux or
`GetFinalPathNameByHandle` on Windows.  The fact that your working
directory contains a symlink doesn't mean that the destination of the
symlink is part of your repository.  In fact, if the destination of your
symlink is on another drive, it cannot be in your repository at all,
since Git cannot handle cross-drive repositories at all.  Since it's not
in the repository, the gitdir pattern won't match.

If I've misunderstood, could you help me understand better by providing
a small shell script that can reproduce the problem you're seeing, so
I can provide a better answer?
-- 
brian m. carlson (they/them or he/him)
Toronto, Ontario, CA

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 262 bytes --]

  reply	other threads:[~2024-05-03 23:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-03 21:31 [Bug Report] git config includeIf not traversing symlink subdirectories Simon Thurston
2024-05-03 23:06 ` brian m. carlson [this message]
     [not found]   ` <B240544D-1695-4627-B7EC-5C9CA7716265@gmail.com>
2024-05-04  1:06     ` brian m. carlson

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=ZjVt5jtC8cKgWpqQ@tapette.crustytoothpaste.net \
    --to=sandals@crustytoothpaste.net \
    --cc=git@vger.kernel.org \
    --cc=simongethurston@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 read-only IMAP folder(s) and NNTP newsgroup(s).