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

Re: [Bug Report] git config includeIf not traversing symlink subdirectories

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
May 3, 2024, 23:06 UTC
Message-ID
<ZjVt5jtC8cKgWpqQ@tapette.crustytoothpaste.net>
In-Reply-To
<CAKx51amU_c9EU+573RWDc0+w3V2u5TSk+mQhts1gYyKRhxGCzQ@mail.gmail.com>
On 2024-05-03 at 21:31:59, Simon Thurston wrote:
Show 10 quoted lines
> 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 ----

Show 9 quoted lines
> 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
Previous: Simon ThurstonNext: brian m. carlson
Message 2 of 3 in “[Bug Report] git config includeIf not traversing symlink subdirectories”
  1. Simon ThurstonMay 3, 2024
  2. brian m. carlsonMay 3, 2024
  3. brian m. carlsonMay 4, 2024

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.