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

Re: Git "safe directory" not working correctly

From
WRWilliam Ruppel <wcruppel@gmail.com>
Date
May 25, 2024, 22:11 UTC
Message-ID
<eecf9177-2557-4af3-a660-6eec63ca854b@gmail.com>
In-Reply-To
<ZlJaXfLc5fvBl4UK@tapette.crustytoothpaste.net>

Thanks Brian, makes perfect sense. Yes, I was using good ol' Windows cmd.exe. So, there is no bug here.

On 05/25/2024 5:38 PM, brian m. carlson wrote:
Show 35 quoted lines
> On 2024-05-25 at 20:22:38, William Ruppel wrote:
>> FYI, I discovered that the issue appears to be related to the single
>> quotes. If I do this instead, then all repos are considered safe:
>>
>> git config --global --add safe.directory *
>>
>> And in a similar vein, to whitelist just the single repo I was having
>> an issue with, git itself  says the command should be:
>>
>> "
>> To add an exception for this directory, call:
>>          git config --global --add safe.directory '\\bill\gitmaster\Src'
>> "
>>
>> But, again, the single quotes don't allow this to work.
>>
>> All the examples I've seen use single quotes. Has something regressed
>> w.r.t. to how single quotes are handled?
> The examples are given for a POSIX shell, where single quotes prevent
> any interpolation or escaping, and double quotes permit interpolation.
> You're running on Windows, probably with CMD or PowerShell, where single
> quotes don't work and would probably be interpreted as part of the
> argument, leading to the `safe.directory` value being `'*'`, not `*`.
>
> Note that at a POSIX shell, not quoting the asterisk will result in it
> being expanded to all files in the current directory, which is why
> quoting is necessary.
>
> If you use Git Bash, then using single quotes is correct.  Otherwise,
> you may need to use double quotes or read the documentation for your
> shell to determine how to properly quote things.  (I don't use Windows,
> so I can't say what the proper syntax is.)  Git itself doesn't
> necessarily know what the shell used to invoke it is (very especially on
> Windows, where SHELL will not be set), so it provides the default POSIX
> command.
Previous: brian m. carlson
Message 4 of 4 in “Git "safe directory" not working correctly”
  1. William RuppelMay 25, 2024
  2. William RuppelMay 25, 2024
  3. brian m. carlsonMay 25, 2024
  4. William RuppelMay 25, 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.