Bug report

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
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@xxxxxxxx
        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@xxxxxxxx
user.name=Test User

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

user config obtained from a repo subdir
user.email=test@xxxxxxxx
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]

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux