Git Mailing List Archive mirror
 help / color / mirror / Atom feed
From: "István Gergely Édes" <edesig@gmail.com>
To: git@vger.kernel.org
Subject: Bug report
Date: Tue, 17 Dec 2024 11:45:37 +0100	[thread overview]
Message-ID: <CAKZ0Q3e3+RtLaQmsW+QCWtv1m05bOGptS8XnZTB1fV=w+ErxEA@mail.gmail.com> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 202 bytes --]

Dear Developers,

I attached my report about some minor inconsistency of the behaviour of the
gitdir directive used within includeIf in the global git config file.

Best regards
Édes I. Gergely

[-- Attachment #1.2: Type: text/html, Size: 277 bytes --]

[-- Attachment #2: git-bugreport-2024-12-17-0930.txt --]
[-- Type: text/plain, Size: 3517 bytes --]

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)

I added a conditional include to my global gitconfig file with a `gitdir` condition
where the glob after gitdir refered a path under a symlinked directory, and called
`git config -l` from a subdirectory of a repository, which matches the glob above.


What did you expect to happen? (Expected behavior)
`git config -l` shows the keys from the included file when it's called in any 
subdirectories of the repo.


What happened instead? (Actual behavior)
`git config -l` shows the keys from the included file when it's called in the 
repo's root directory, but not, when it's called in a subdirectory.

What's different between what you expected and what actually happened?
The behaviour of `git config -l` in some subdirectories of the repo.

Anything else you want to add:
1) I was able reproduce this behaviour on an Ubuntu hosted on WSL2 with the following script
```
#!/usr/bin/env sh

readonly LINKED_DIR="$(mktemp -d)"
readonly TEST_DIRECTORY="$HOME/debug_git_includeIf"
readonly TARGET_DIRECTORY="$TEST_DIRECTORY/target"
readonly REPO_DIRECTORY="$TARGET_DIRECTORY/repo"
readonly REPO_SUBDIRECTORY="$REPO_DIRECTORY/subdir"
readonly GLOBAL_CONFIG="$(mktemp)"
readonly CONFIG_TO_BE_INCLUDED="$TARGET_DIRECTORY/.gitconfig"

debug(){
	"$@" >&2
}

# Prepare directories
unlink $TEST_DIRECTORY
ln -s $LINKED_DIR $TEST_DIRECTORY
mkdir -p "$REPO_SUBDIRECTORY"

# Prepare config file
cat > "$GLOBAL_CONFIG" << EOF
[core]
        fileMode = false
        editor = vim
[init]
	defaultbranch=grandmaster
[includeIf "gitdir:$TARGET_DIRECTORY/"]
       path = $CONFIG_TO_BE_INCLUDED
EOF

cat > "$CONFIG_TO_BE_INCLUDED" << EOF
[user]
        email = test@mail.com
        name = Test User
EOF

debug echo "global config at $GLOBAL_CONFIG"
debug cat "$GLOBAL_CONFIG"
debug echo
debug echo "config to be included at $CONFIG_TO_BE_INCLUDED"
debug cat "$CONFIG_TO_BE_INCLUDED" 


cd "$REPO_DIRECTORY"

debug export GIT_CONFIG_GLOBAL="$GLOBAL_CONFIG"
debug git init
FILE_TO_COMMIT="$REPO_SUBDIRECTORY/file"
debug touch "$FILE_TO_COMMIT"

debug git add "$FILE_TO_COMMIT"
debug git commit -m "initial commit" . 

echo user config obtained from the repo root
git config -l | grep user

cd "$REPO_SUBDIRECTORY"
echo
echo user config obtained from a repo subdir
debug pwd
git config -l | grep user
```
Once I saved it into the executable `reproduce.sh` file running
```
./reproduce.sh 2> /dev/null
```
gives the following output
```
user config obtained from the repo root
user.email=test@mail.com
user.name=Test User

user config obtained from a repo subdir
```
instead of
```
user config obtained from the repo root
user.email=test@mail.com
user.name=Test User

user config obtained from a repo subdir
user.email=test@mail.com
user.name=Test User
```
2) Workaround
Changing the glob in the gitdir directive to one refferring to an
absolute path resolved my issue.

Please review the rest of the bug report below.
You can delete any lines you don't wish to share.


[System Info]
git version:
git version 2.47.1
cpu: x86_64
no commit associated with this build
sizeof-long: 8
sizeof-size_t: 8
shell-path: /bin/sh
libcurl: 8.5.0
zlib: 1.3
uname: Linux 5.15.153.1-microsoft-standard-WSL2 #1 SMP Fri Mar 29 23:14:13 UTC 2024 x86_64
compiler info: gnuc: 13.2
libc info: glibc: 2.39
$SHELL (typically, interactive shell): /bin/bash


[Enabled Hooks]

             reply	other threads:[~2024-12-17 10:45 UTC|newest]

Thread overview: 80+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-17 10:45 István Gergely Édes [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-11-15 13:02 Bug Report Sachin tiwari
2024-11-15 20:08 ` brian m. carlson
2024-10-13 15:44 =?gb18030?B?zuLUqsrY?=
2024-10-14  5:04 ` Koji Nakamaru
2024-10-14  6:02   ` Johannes Schindelin
2024-10-14  6:22     ` Koji Nakamaru
2024-10-15  0:40       ` Taylor Blau
2024-10-09  3:23 Bug report Ed Reel
2024-10-14  6:10 ` Johannes Schindelin
2024-07-19 18:34 Roman Dvoskin
2024-07-19 20:13 ` brian m. carlson
2024-07-19 20:35   ` Roman Dvoskin
2024-07-19 20:40   ` rsbecker
2023-08-28 12:51 Dexter Pontañeles
2023-06-27 16:02 Bug Report Tiago d'Almeida
2022-12-28  2:43 Bug report Jensen Bean
2022-12-28  5:02 ` Eric Sunshine
2022-12-25 17:26 bug report Eyal Post
2022-12-25 18:12 ` Eric Sunshine
2022-12-08  5:29 Bug Report Jensen Bean
2022-12-08  8:31 ` Bagas Sanjaya
     [not found]   ` <CANqKdC-gHgQHn5DMoOREY52y7PpRLMpNAjX3qeA5iy9z_GXdzw@mail.gmail.com>
2022-12-26  2:15     ` Bagas Sanjaya
2022-11-19 20:20 Jensen Bean
2022-10-03 15:28 Bug report Alastair Douglas
2022-10-03 16:53 ` Junio C Hamano
2022-10-04 10:15   ` Alastair Douglas
2022-10-05  5:46     ` Junio C Hamano
2022-04-20 19:45 Bug Report Daniel Habenicht
2022-04-20 21:30 ` brian m. carlson
2022-04-20 22:34   ` rsbecker
2022-04-21 13:20     ` Daniel Habenicht
2022-04-21 14:39       ` Torsten Bögershausen
     [not found]         ` <AS1P190MB175022A7F1264807ECA464A8ECF49@AS1P190MB1750.EURP190.PROD.OUTLOOK.COM>
2022-04-21 17:52           ` Torsten Bögershausen
2021-12-01 22:31 Josh Rampersad
2021-11-12  4:22 bug report Theodore Li
2021-11-12  4:29 ` Junio C Hamano
2021-11-12  6:59   ` Theodore Li
2021-11-12 14:05     ` Paul Smith
2020-03-27 11:53 Bug Report James Yeoman
2020-03-27 12:59 ` Pratyush Yadav
     [not found] <CA+2sEepTyrK-iH+VBHVF1i9DuYVzDkTNxuM0-yoWbkC9N4f8HA@mail.gmail.com>
2019-04-15 15:18 ` bug report Nick Steinhauser
2017-08-30 21:25 Bug report Aleksandar Pavic
2017-08-31  6:36 ` Kevin Daudt
2017-08-31 14:19   ` Dov Grobgeld
2017-08-31 14:55     ` Aleksandar Pavic
2017-08-31 16:23   ` Stephan Beyer
2017-09-02  8:49 ` Jeff King
2016-05-13  5:04 bug report 李本超
2016-05-13  5:23 ` Pranit Bauva
2016-05-13  5:58   ` 李本超
2016-05-13  6:37     ` Pranit Bauva
2016-05-13  6:57       ` 李本超
2016-05-13  7:10         ` Pranit Bauva
2016-05-13  7:41           ` 李本超
2016-05-13  8:10             ` Jeff King
2016-05-13 12:05               ` 李本超
2016-04-03  0:25 Bug Report Benjamin Sandeen
2016-04-03  2:20 ` Eric N. Vander Weele
2016-04-03  2:22 ` Jacob Keller
2015-01-27 14:43 bug report Albert Akhriev
2015-01-27 14:50 ` Jeff King
     [not found] <CAC34_pT9zwZDnUjo1bTUZabD02M48=_+77-mNCA5adWTgxuYgg@mail.gmail.com>
2013-04-08  5:20 ` Bug Report Kirk Fraser
2012-10-05 10:13 Bug report Муковников Михаил
2012-10-05 10:32 ` Konstantin Khomoutov
2012-10-05 10:47   ` Carlos Martín Nieto
2012-10-05 11:03     ` Муковников Михаил
2012-10-05 10:52   ` Муковников Михаил
2012-10-04  4:35 John Whitney
2012-10-04 14:19 ` Phil Hord
2012-10-04 16:10   ` John Whitney
2012-10-06 13:31     ` Jeff King
2012-10-07  2:23       ` John Whitney
2012-10-07 23:52         ` Jeff King
2012-10-09 17:17           ` John Whitney
2012-10-09 19:00             ` John Whitney
2012-10-04 15:21 ` Andrew Wong
2012-10-04 16:16   ` John Whitney
2012-10-04 16:28     ` John Whitney
2012-10-04 17:01     ` Andrew Wong

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='CAKZ0Q3e3+RtLaQmsW+QCWtv1m05bOGptS8XnZTB1fV=w+ErxEA@mail.gmail.com' \
    --to=edesig@gmail.com \
    --cc=git@vger.kernel.org \
    /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).