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

Re: 'safe.directory' setting ignored for some operations?

From
NRNikolaus Rath <nikolaus@quadrature.ai>
Date
Apr 11, 2025, 08:17 UTC
Message-ID
<CAPzgaL3tYJay9P_VvuqSKRuta8FFgn=xc7P=2t3MFukbobiFOw@mail.gmail.com>
In-Reply-To
<20250410213542.GA3168175@coredump.intra.peff.net>
On Thu, 10 Apr 2025 at 22:35, Jeff King <peff@peff.net> wrote:
Show 15 quoted lines
>
> On Thu, Apr 10, 2025 at 02:21:01PM +0100, Nikolaus Rath wrote:
>
> > It seems to me that the 'safe.directory = *' option is ignored for
> > some operations:
> >
> > ---snip--
> > $ git --version
> > git version 2.43.0
> >
> > $ git config --get-all --show-scope safe.directory
> > command *
>
> You're getting "command" here, but I don't see any "-c". Presumably
> you're setting GIT_CONFIG_* in the environment yourself?
Yes.
Show 9 quoted lines
>
> > $ git status -v --untracked=all --ignored
> > HEAD detached at e116555
> > [...]
> > nothing to commit, working tree clean
>
> You don't show us the repo here, but presumably this is one you don't
> own, and the config is working as expected to allow the operation to
> proceed.
Exactly.
Show 22 quoted lines
>
> > $ git clone -v --no-checkout --
> > /builds/coreinfra/grafana_terraform/.git
> > /builds/coreinfra/grafana_terraform/tmpus18hzbs
> > Cloning into '/builds/coreinfra/grafana_terraform/tmpus18hzbs'...
> > fatal: detected dubious ownership in repository at
> > '/builds/coreinfra/grafana_terraform/.git'
> > To add an exception for this directory, call:
> >
> > git config --global --add safe.directory
> > /builds/coreinfra/grafana_terraform/.git
> > fatal: Could not read from remote repository.
> >
> > Please make sure you have the correct access rights
> > and the repository exists.
>
> Here you are running afoul of the environment-clearing that happens when
> Git internally "switches" to another repo. The "clone" command is run in
> your newly-made repo (which is "safe"), but it would then run
> "git-upload-pack" in the remote repo to act as the server side. We clear
> out many Git-related environment variables when switching between
> variables, including GIT_CONFIG_*.

Ah, that explains it indeed. Thank you very much! And apologies for not being fully clear about the context.

Best, -Nikolaus

-- 
nikolaus@quadrature.ai

https://quadrature.ai
Dir: +44-20-8145-4726 Main: +44-20-3743-0400
The Leadenhall Building, 122 Leadenhall Street, London, EC3V 4AB
Previous: brian m. carlson
Message 6 of 6 in “'safe.directory' setting ignored for some operations?”
  1. Nikolaus RathApr 10, 2025
  2. Jeff KingApr 10, 2025
  3. brian m. carlsonApr 10, 2025
  4. Jeff KingApr 10, 2025
  5. brian m. carlsonApr 11, 2025
  6. Nikolaus RathApr 11, 2025

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.