{"thread":{"id":"55626","subject":"BUG: Git path --config doesn't work with ~ symbol","startedAt":"2021-05-05T18:06:40Z","lastAt":"2021-05-05T19:01:49Z","messageCount":9,"participants":["Theodor Negrescu","Jeff King","Eric Sunshine"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"423703","messageId":"CAEumJaDRvU8LP=q3PQ1z6-cg75DmbHE_7OXZVA+nm=-77pVLEg@mail.gmail.com","threadId":"55626","inReplyTo":null,"subject":"BUG: Git path --config doesn't work with ~ symbol","fromName":"Theodor Negrescu","fromEmail":"theodor.negrescu@gmail.com","sentAt":"2021-05-05T18:06:12Z","receivedAt":"2021-05-05T18:06:40Z","isPatch":false,"sender":{"key":"theodor.negrescu@gmail.com","avatar":null},"body":"Thank 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 ran the command \"git config --file ~/git-settings/.gitconfig -l\"\n(git-settings is a repo where I keep my config, the global one is just\nan include)\n\nWhat did you expect to happen? (Expected behavior)\n\nIt would list the settings in the file.\n\nWhat happened instead? (Actual behavior)\n\nfatal: unable to read config file '~/git-settings/.gitconfig': No such\nfile or directory\n\nWhat's different between what you expected and what actually happened?\n\nThe ~ symbol should point to my home folder.\n\nAnything else you want to add:\n\n\"git config --file ~/.gitconfig -l\" doesn't work either so the ~\nsymbol is the problem.\nfatal: unable to read config file '~/.gitconfig': No such file or directory\n\"git config --file .gitconfig -l\" works when I run it from my home\nfolder or from git-settings so the --file argument is working.\n\n[System Info]\ngit version:\ngit version 2.31.1.windows.1\ncpu: x86_64\nbuilt from commit: c5f0be26a7e3846e3b6268d1c6c4800d838c6bbb\nsizeof-long: 4\nsizeof-size_t: 8\nshell-path: /bin/sh\nfeature: fsmonitor--daemon\nuname: Windows 10.0 19042\ncompiler info: gnuc: 10.2\nlibc info: no libc information available\n$SHELL (typically, interactive shell): <unset>\n\n\n[Enabled Hooks]\nnot run from a git repository - no hooks to show\n"},{"id":"423704","messageId":"CAEumJaBDqSyqbnvWSeCyXYQJz92dOg+y1pz2JLjPSMRzWxc1aA@mail.gmail.com","threadId":"55626","inReplyTo":"CAEumJaDRvU8LP=q3PQ1z6-cg75DmbHE_7OXZVA+nm=-77pVLEg@mail.gmail.com","subject":"Re: BUG: Git path --config doesn't work with ~ symbol","fromName":"Theodor Negrescu","fromEmail":"theodor.negrescu@gmail.com","sentAt":"2021-05-05T18:13:58Z","receivedAt":"2021-05-05T18:14:15Z","isPatch":false,"sender":{"key":"theodor.negrescu@gmail.com","avatar":null},"body":"I meant Git config --file!! Sorry, I wrote the wrong thing in the title.\n\nOn Wed, May 5, 2021 at 9:06 PM Theodor Negrescu\n<theodor.negrescu@gmail.com> wrote:\n>\n> Thank you for filling out a Git bug report!\n> Please answer the following questions to help us understand your issue.\n>\n> What did you do before the bug happened? (Steps to reproduce your issue)\n>\n> I ran the command \"git config --file ~/git-settings/.gitconfig -l\"\n> (git-settings is a repo where I keep my config, the global one is just\n> an include)\n>\n> What did you expect to happen? (Expected behavior)\n>\n> It would list the settings in the file.\n>\n> What happened instead? (Actual behavior)\n>\n> fatal: unable to read config file '~/git-settings/.gitconfig': No such\n> file or directory\n>\n> What's different between what you expected and what actually happened?\n>\n> The ~ symbol should point to my home folder.\n>\n> Anything else you want to add:\n>\n> \"git config --file ~/.gitconfig -l\" doesn't work either so the ~\n> symbol is the problem.\n> fatal: unable to read config file '~/.gitconfig': No such file or directory\n> \"git config --file .gitconfig -l\" works when I run it from my home\n> folder or from git-settings so the --file argument is working.\n>\n> [System Info]\n> git version:\n> git version 2.31.1.windows.1\n> cpu: x86_64\n> built from commit: c5f0be26a7e3846e3b6268d1c6c4800d838c6bbb\n> sizeof-long: 4\n> sizeof-size_t: 8\n> shell-path: /bin/sh\n> feature: fsmonitor--daemon\n> uname: Windows 10.0 19042\n> compiler info: gnuc: 10.2\n> libc info: no libc information available\n> $SHELL (typically, interactive shell): <unset>\n>\n>\n> [Enabled Hooks]\n> not run from a git repository - no hooks to show\n"},{"id":"423705","messageId":"YJLgmXS/fJm1BQb4@coredump.intra.peff.net","threadId":"55626","inReplyTo":"CAEumJaDRvU8LP=q3PQ1z6-cg75DmbHE_7OXZVA+nm=-77pVLEg@mail.gmail.com","subject":"Re: BUG: Git path --config doesn't work with ~ symbol","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2021-05-05T18:14:49Z","receivedAt":"2021-05-05T18:14:52Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, May 05, 2021 at 09:06:12PM +0300, Theodor Negrescu wrote:\n\n> What did you do before the bug happened? (Steps to reproduce your issue)\n> \n> I ran the command \"git config --file ~/git-settings/.gitconfig -l\"\n> (git-settings is a repo where I keep my config, the global one is just\n> an include)\n> \n> What did you expect to happen? (Expected behavior)\n> \n> It would list the settings in the file.\n> \n> What happened instead? (Actual behavior)\n> \n> fatal: unable to read config file '~/git-settings/.gitconfig': No such\n> file or directory\n> \n> What's different between what you expected and what actually happened?\n> \n> The ~ symbol should point to my home folder.\n\nI don't think this is a bug in git-config. It is generally the shell\nthat is responsible for expanding \"~\" and passing along the result to\ncommands. E.g.:\n\n  $ strace -e execve git config --file ~/foo --list\n  execve(\"/home/peff/local/git/current/bin/git\", [\"git\", \"config\", \"--file\", \"/home/peff/foo\", \"--list\"], 0x7ffc10a88130 /* 55 vars */) = 0\n\n> [System Info]\n> git version:\n> git version 2.31.1.windows.1\n> cpu: x86_64\n> built from commit: c5f0be26a7e3846e3b6268d1c6c4800d838c6bbb\n> sizeof-long: 4\n> sizeof-size_t: 8\n> shell-path: /bin/sh\n> feature: fsmonitor--daemon\n> uname: Windows 10.0 19042\n> compiler info: gnuc: 10.2\n> libc info: no libc information available\n> $SHELL (typically, interactive shell): <unset>\n\nI'd guess this might be related to Windows somehow. Are you entering the\ncommand in a bash shell, or via some other mechanism?\n\n-Peff\n"},{"id":"423706","messageId":"CAPig+cTX179z5MrTvSmgYGzZdc4xz=2G_ffHsyVOXsKVHrL93w@mail.gmail.com","threadId":"55626","inReplyTo":"YJLgmXS/fJm1BQb4@coredump.intra.peff.net","subject":"Re: BUG: Git path --config doesn't work with ~ symbol","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2021-05-05T18:21:38Z","receivedAt":"2021-05-05T18:21:53Z","isPatch":false,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Wed, May 5, 2021 at 2:14 PM Jeff King <peff@peff.net> wrote:\n> On Wed, May 05, 2021 at 09:06:12PM +0300, Theodor Negrescu wrote:\n> > I ran the command \"git config --file ~/git-settings/.gitconfig -l\"\n> > (git-settings is a repo where I keep my config, the global one is just\n> > an include)\n>\n> I don't think this is a bug in git-config. It is generally the shell\n> that is responsible for expanding \"~\" and passing along the result to\n> commands. E.g.:\n>\n>   $ strace -e execve git config --file ~/foo --list\n>   execve(\"/home/peff/local/git/current/bin/git\", [\"git\", \"config\", \"--file\", \"/home/peff/foo\", \"--list\"], 0x7ffc10a88130 /* 55 vars */) = 0\n>\n> I'd guess this might be related to Windows somehow. Are you entering the\n> command in a bash shell, or via some other mechanism?\n\nIs OPT_FILENAME supposed to handle tilde-expansion? I ask because\ngit-config is using OPT_STRING for this option, whereas other commands\nuse OPT_FILENAME for their `--file` options.\n"},{"id":"423707","messageId":"CAEumJaCmcReO4ry7DP14zDg0R5L5QgULZpZmaqBY5g=EQD4U+Q@mail.gmail.com","threadId":"55626","inReplyTo":"CAPig+cTX179z5MrTvSmgYGzZdc4xz=2G_ffHsyVOXsKVHrL93w@mail.gmail.com","subject":"Re: BUG: Git path --config doesn't work with ~ symbol","fromName":"Theodor Negrescu","fromEmail":"theodor.negrescu@gmail.com","sentAt":"2021-05-05T18:30:21Z","receivedAt":"2021-05-05T18:30:40Z","isPatch":false,"sender":{"key":"theodor.negrescu@gmail.com","avatar":null},"body":"I'm using powershell, but usually ~ works there. Typing \"cd ~\" would\nwork for example.\nAlso I tried using the command as an alias and it still didn't work.\n\nOn Wed, May 5, 2021 at 9:21 PM Eric Sunshine <sunshine@sunshineco.com> wrote:\n>\n> On Wed, May 5, 2021 at 2:14 PM Jeff King <peff@peff.net> wrote:\n> > On Wed, May 05, 2021 at 09:06:12PM +0300, Theodor Negrescu wrote:\n> > > I ran the command \"git config --file ~/git-settings/.gitconfig -l\"\n> > > (git-settings is a repo where I keep my config, the global one is just\n> > > an include)\n> >\n> > I don't think this is a bug in git-config. It is generally the shell\n> > that is responsible for expanding \"~\" and passing along the result to\n> > commands. E.g.:\n> >\n> >   $ strace -e execve git config --file ~/foo --list\n> >   execve(\"/home/peff/local/git/current/bin/git\", [\"git\", \"config\", \"--file\", \"/home/peff/foo\", \"--list\"], 0x7ffc10a88130 /* 55 vars */) = 0\n> >\n> > I'd guess this might be related to Windows somehow. Are you entering the\n> > command in a bash shell, or via some other mechanism?\n>\n> Is OPT_FILENAME supposed to handle tilde-expansion? I ask because\n> git-config is using OPT_STRING for this option, whereas other commands\n> use OPT_FILENAME for their `--file` options.\n"},{"id":"423708","messageId":"YJLkw59nxAU6/vVT@coredump.intra.peff.net","threadId":"55626","inReplyTo":"CAPig+cTX179z5MrTvSmgYGzZdc4xz=2G_ffHsyVOXsKVHrL93w@mail.gmail.com","subject":"Re: BUG: Git path --config doesn't work with ~ symbol","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2021-05-05T18:32:35Z","receivedAt":"2021-05-05T18:32:38Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, May 05, 2021 at 02:21:38PM -0400, Eric Sunshine wrote:\n\n> On Wed, May 5, 2021 at 2:14 PM Jeff King <peff@peff.net> wrote:\n> > On Wed, May 05, 2021 at 09:06:12PM +0300, Theodor Negrescu wrote:\n> > > I ran the command \"git config --file ~/git-settings/.gitconfig -l\"\n> > > (git-settings is a repo where I keep my config, the global one is just\n> > > an include)\n> >\n> > I don't think this is a bug in git-config. It is generally the shell\n> > that is responsible for expanding \"~\" and passing along the result to\n> > commands. E.g.:\n> >\n> >   $ strace -e execve git config --file ~/foo --list\n> >   execve(\"/home/peff/local/git/current/bin/git\", [\"git\", \"config\", \"--file\", \"/home/peff/foo\", \"--list\"], 0x7ffc10a88130 /* 55 vars */) = 0\n> >\n> > I'd guess this might be related to Windows somehow. Are you entering the\n> > command in a bash shell, or via some other mechanism?\n> \n> Is OPT_FILENAME supposed to handle tilde-expansion? I ask because\n> git-config is using OPT_STRING for this option, whereas other commands\n> use OPT_FILENAME for their `--file` options.\n\nNo, I don't think so. The point of OPT_FILENAME() is that it handles the\ndirectory-change from setting up the git directory before we even the\nthe cmd_*() function.\n\nBut that isn't necessary here, because cmd_config() applies the prefix\nmanually. So this works as expected:\n\n  $ git init\n  $ mkdir subdir\n  $ git config --file=foo my.dir root\n  $ git config --file=subdir/foo my.dir sub\n  $ git config --file=foo --list\n  my.dir=root\n  $ cd subdir\n  $ git config --file=foo --list\n  my.dir=sub\n\nPossibly the code could be simplified a little by using OPT_FILENAME(),\nthough.\n\n-Peff\n"},{"id":"423709","messageId":"YJLla4gNEMS2yxCv@coredump.intra.peff.net","threadId":"55626","inReplyTo":"CAEumJaCmcReO4ry7DP14zDg0R5L5QgULZpZmaqBY5g=EQD4U+Q@mail.gmail.com","subject":"Re: BUG: Git path --config doesn't work with ~ symbol","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2021-05-05T18:35:23Z","receivedAt":"2021-05-05T18:35:27Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, May 05, 2021 at 09:30:21PM +0300, Theodor Negrescu wrote:\n\n> I'm using powershell, but usually ~ works there. Typing \"cd ~\" would\n> work for example.\n> Also I tried using the command as an alias and it still didn't work.\n\nI don't know anything about powershell, but generally \"cd\" is a builtin\nto the shell (because it is impacting the shell's environment). So it\nmay be that powershell \"cd\" expands \"~\" itself, but that the shell\ndoesn't expand it for executed commands.\n\nThere are some Windows folks who hang out on this list, so you may get a\nbetter response. But you might also ask in the Git for Windows mailing\nlist:\n\n  https://groups.google.com/g/git-for-windows\n\n-Peff\n"},{"id":"423711","messageId":"CAEumJaA7NBm9Kdx7aCD1gavGguLmGcnvFcA52YvUk7g_FPzHZw@mail.gmail.com","threadId":"55626","inReplyTo":"YJLla4gNEMS2yxCv@coredump.intra.peff.net","subject":"Re: BUG: Git path --config doesn't work with ~ symbol","fromName":"Theodor Negrescu","fromEmail":"theodor.negrescu@gmail.com","sentAt":"2021-05-05T18:59:58Z","receivedAt":"2021-05-05T19:00:16Z","isPatch":false,"sender":{"key":"theodor.negrescu@gmail.com","avatar":null},"body":"You're right, \"notepad ~/test.txt\" doesn't work either.\nI figured out a workaround:\n[alias]\n    cfg = \"!git config --file $(echo ~)/git-settings/.gitconfig \"\nHowever what confuses me is that I also have\n[core]\n    hooksPath = ~/git-settings/hooks\nand that ~ works. So why doesn't it work in config --file?\n\nOn Wed, May 5, 2021 at 9:35 PM Jeff King <peff@peff.net> wrote:\n>\n> On Wed, May 05, 2021 at 09:30:21PM +0300, Theodor Negrescu wrote:\n>\n> > I'm using powershell, but usually ~ works there. Typing \"cd ~\" would\n> > work for example.\n> > Also I tried using the command as an alias and it still didn't work.\n>\n> I don't know anything about powershell, but generally \"cd\" is a builtin\n> to the shell (because it is impacting the shell's environment). So it\n> may be that powershell \"cd\" expands \"~\" itself, but that the shell\n> doesn't expand it for executed commands.\n>\n> There are some Windows folks who hang out on this list, so you may get a\n> better response. But you might also ask in the Git for Windows mailing\n> list:\n>\n>   https://groups.google.com/g/git-for-windows\n>\n> -Peff\n"},{"id":"423712","messageId":"YJLrm0nqWL6TnUFb@coredump.intra.peff.net","threadId":"55626","inReplyTo":"CAEumJaA7NBm9Kdx7aCD1gavGguLmGcnvFcA52YvUk7g_FPzHZw@mail.gmail.com","subject":"Re: BUG: Git path --config doesn't work with ~ symbol","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2021-05-05T19:01:47Z","receivedAt":"2021-05-05T19:01:49Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, May 05, 2021 at 09:59:58PM +0300, Theodor Negrescu wrote:\n\n> You're right, \"notepad ~/test.txt\" doesn't work either.\n> I figured out a workaround:\n> [alias]\n>     cfg = \"!git config --file $(echo ~)/git-settings/.gitconfig \"\n> However what confuses me is that I also have\n> [core]\n>     hooksPath = ~/git-settings/hooks\n> and that ~ works. So why doesn't it work in config --file?\n\nSome config options that refer to paths specifically expand \"~\", exactly\nbecause there is no shell involved when Git reads them.\n\n-Peff\n"}]}