From 6cade5c9d59566314fe63d30f648dde1abe33a32 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 5 Sep 2014 13:44:09 -0400 Subject: New annex.hardlink setting. Closes: #758593 * New annex.hardlink setting. Closes: #758593 * init: Automatically detect when a repository was cloned with --shared, and set annex.hardlink=true, as well as marking the repository as untrusted. Had to reorganize Logs.Trust a bit to avoid a cycle between it and Annex.Init. --- Git/Objects.hs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'Git/Objects.hs') diff --git a/Git/Objects.hs b/Git/Objects.hs index 516aa6d3e..dadd4f543 100644 --- a/Git/Objects.hs +++ b/Git/Objects.hs @@ -33,3 +33,17 @@ looseObjectFile :: Repo -> Sha -> FilePath looseObjectFile r sha = objectsDir r prefix rest where (prefix, rest) = splitAt 2 (fromRef sha) + +listAlternates :: Repo -> IO [FilePath] +listAlternates r = catchDefaultIO [] (lines <$> readFile alternatesfile) + where + alternatesfile = objectsDir r "info" "alternates" + +{- A repository recently cloned with --shared will have one or more + - alternates listed, and contain no loose objects or packs. -} +isSharedClone :: Repo -> IO Bool +isSharedClone r = allM id + [ not . null <$> listAlternates r + , null <$> listLooseObjectShas r + , null <$> listPackFiles r + ] -- cgit v1.2.3