{"thread":{"id":"62652","subject":"Bug report","startedAt":"2024-12-17T10:45:43Z","lastAt":"2024-12-17T10:45:43Z","messageCount":1,"participants":["István Gergely Édes"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"509210","messageId":"CAKZ0Q3e3+RtLaQmsW+QCWtv1m05bOGptS8XnZTB1fV=w+ErxEA@mail.gmail.com","threadId":"62652","inReplyTo":null,"subject":"Bug report","fromName":"István Gergely Édes","fromEmail":"edesig@gmail.com","sentAt":"2024-12-17T10:45:37Z","receivedAt":"2024-12-17T10:45:43Z","isPatch":false,"sender":{"key":"edesig@gmail.com","avatar":null},"body":"Dear Developers,\n\nI attached my report about some minor inconsistency of the behaviour of the\ngitdir directive used within includeIf in the global git config file.\n\nBest regards\nÉdes I. Gergely\n\n\nThank you for filling out a Git bug report!\nPlease answer the following questions to help us understand your issue.\n\nWhat did you do before the bug happened? (Steps to reproduce your issue)\n\nI added a conditional include to my global gitconfig file with a `gitdir` condition\nwhere the glob after gitdir refered a path under a symlinked directory, and called\n`git config -l` from a subdirectory of a repository, which matches the glob above.\n\n\nWhat did you expect to happen? (Expected behavior)\n`git config -l` shows the keys from the included file when it's called in any \nsubdirectories of the repo.\n\n\nWhat happened instead? (Actual behavior)\n`git config -l` shows the keys from the included file when it's called in the \nrepo's root directory, but not, when it's called in a subdirectory.\n\nWhat's different between what you expected and what actually happened?\nThe behaviour of `git config -l` in some subdirectories of the repo.\n\nAnything else you want to add:\n1) I was able reproduce this behaviour on an Ubuntu hosted on WSL2 with the following script\n```\n#!/usr/bin/env sh\n\nreadonly LINKED_DIR=\"$(mktemp -d)\"\nreadonly TEST_DIRECTORY=\"$HOME/debug_git_includeIf\"\nreadonly TARGET_DIRECTORY=\"$TEST_DIRECTORY/target\"\nreadonly REPO_DIRECTORY=\"$TARGET_DIRECTORY/repo\"\nreadonly REPO_SUBDIRECTORY=\"$REPO_DIRECTORY/subdir\"\nreadonly GLOBAL_CONFIG=\"$(mktemp)\"\nreadonly CONFIG_TO_BE_INCLUDED=\"$TARGET_DIRECTORY/.gitconfig\"\n\ndebug(){\n\t\"$@\" >&2\n}\n\n# Prepare directories\nunlink $TEST_DIRECTORY\nln -s $LINKED_DIR $TEST_DIRECTORY\nmkdir -p \"$REPO_SUBDIRECTORY\"\n\n# Prepare config file\ncat > \"$GLOBAL_CONFIG\" << EOF\n[core]\n        fileMode = false\n        editor = vim\n[init]\n\tdefaultbranch=grandmaster\n[includeIf \"gitdir:$TARGET_DIRECTORY/\"]\n       path = $CONFIG_TO_BE_INCLUDED\nEOF\n\ncat > \"$CONFIG_TO_BE_INCLUDED\" << EOF\n[user]\n        email = test@mail.com\n        name = Test User\nEOF\n\ndebug echo \"global config at $GLOBAL_CONFIG\"\ndebug cat \"$GLOBAL_CONFIG\"\ndebug echo\ndebug echo \"config to be included at $CONFIG_TO_BE_INCLUDED\"\ndebug cat \"$CONFIG_TO_BE_INCLUDED\" \n\n\ncd \"$REPO_DIRECTORY\"\n\ndebug export GIT_CONFIG_GLOBAL=\"$GLOBAL_CONFIG\"\ndebug git init\nFILE_TO_COMMIT=\"$REPO_SUBDIRECTORY/file\"\ndebug touch \"$FILE_TO_COMMIT\"\n\ndebug git add \"$FILE_TO_COMMIT\"\ndebug git commit -m \"initial commit\" . \n\necho user config obtained from the repo root\ngit config -l | grep user\n\ncd \"$REPO_SUBDIRECTORY\"\necho\necho user config obtained from a repo subdir\ndebug pwd\ngit config -l | grep user\n```\nOnce I saved it into the executable `reproduce.sh` file running\n```\n./reproduce.sh 2> /dev/null\n```\ngives the following output\n```\nuser config obtained from the repo root\nuser.email=test@mail.com\nuser.name=Test User\n\nuser config obtained from a repo subdir\n```\ninstead of\n```\nuser config obtained from the repo root\nuser.email=test@mail.com\nuser.name=Test User\n\nuser config obtained from a repo subdir\nuser.email=test@mail.com\nuser.name=Test User\n```\n2) Workaround\nChanging the glob in the gitdir directive to one refferring to an\nabsolute path resolved my issue.\n\nPlease review the rest of the bug report below.\nYou can delete any lines you don't wish to share.\n\n\n[System Info]\ngit version:\ngit version 2.47.1\ncpu: x86_64\nno commit associated with this build\nsizeof-long: 8\nsizeof-size_t: 8\nshell-path: /bin/sh\nlibcurl: 8.5.0\nzlib: 1.3\nuname: Linux 5.15.153.1-microsoft-standard-WSL2 #1 SMP Fri Mar 29 23:14:13 UTC 2024 x86_64\ncompiler info: gnuc: 13.2\nlibc info: glibc: 2.39\n$SHELL (typically, interactive shell): /bin/bash\n\n\n[Enabled Hooks]\n"}]}