pass --git-dir, rather than changing cwd
authorJoey Hess <joeyh@joeyh.name>
Fri, 23 Oct 2020 17:36:56 +0000 (13:36 -0400)
committerJoey Hess <joeyh@joeyh.name>
Fri, 23 Oct 2020 17:36:56 +0000 (13:36 -0400)
If .git is a gitlink file, setting cwd to it will fail, but --git-dir
will succeed. And this is the only place where it sets cwd when running
git, everywhere else already uses --git-dir.

Note that, git-annex's submodule fixup code usually converts gitlink
files to symlinks, so this wasn't usually problem. Still, worth fixing.

This commit was sponsored by Svenne Krap on Patreon.

Git/Config.hs

index 45cf4aa8fb69aa58efe4f8b9171832358cb4d21e..db1bc3c19b4ceeae38acd27cab38287112528aa1 100644 (file)
@@ -61,10 +61,15 @@ read' repo = go repo
        go _ = assertLocal repo $ error "internal"
        git_config d = withCreateProcess p (git_config' p)
          where
-               params = ["config", "--null", "--list"]
+               params =
+                       [ "--git-dir"
+                       , fromRawFilePath d
+                       , "config"
+                       , "--null"
+                       , "--list"
+                       ]
                p = (proc "git" params)
-                       { cwd = Just (fromRawFilePath d)
-                       , env = gitEnv repo
+                       { env = gitEnv repo
                        , std_out = CreatePipe 
                        }
        git_config' p _ (Just hout) _ pid =