make path absolute for display
authorJoey Hess <joeyh@joeyh.name>
Tue, 31 May 2022 16:17:27 +0000 (12:17 -0400)
committerJoey Hess <joeyh@joeyh.name>
Tue, 31 May 2022 16:17:27 +0000 (12:17 -0400)
Avoid suggesting the user add "." to safe.directory.

Annex/Init.hs

index 62767dece79548874bce6bf516a27c48068ffd4e..afe73954f29680f1f9947f406f89d2cbc1855b33 100644 (file)
@@ -229,19 +229,20 @@ objectDirNotPresent = do
        return (not exists)
 
 guardSafeToUseRepo :: Annex a -> Annex a
-guardSafeToUseRepo a = do
-       repopath <- fromRepo Git.repoPath
-       ifM (inRepo Git.Config.checkRepoConfigInaccessible)
-               ( giveup $ unlines $
+guardSafeToUseRepo a = ifM (inRepo Git.Config.checkRepoConfigInaccessible)
+       ( do
+               repopath <- fromRepo Git.repoPath
+               p <- liftIO $ absPath repopath
+               giveup $ unlines $
                        [ "Git refuses to operate in this repository,"
                        , "probably because it is owned by someone else."
                        , ""
                        -- This mirrors git's wording.
                        , "To add an exception for this directory, call:"
-                       , "\tgit config --global --add safe.directory " ++ fromRawFilePath repopath
+                       , "\tgit config --global --add safe.directory " ++ fromRawFilePath p
                        ]
-               , a
-               )
+       , a
+       )
 
 {- Initialize if it can do so automatically. Avoids failing if it cannot.
  -