summaryrefslogtreecommitdiff
path: root/Git/Objects.hs
diff options
context:
space:
mode:
authorJoey Hess <joey@kitenet.net>2014-10-12 14:32:56 -0400
committerJoey Hess <joey@kitenet.net>2014-10-12 14:32:56 -0400
commitefef527d5b2e42e261fa7af6947aad6553426ebe (patch)
tree082a5dad993557e9dffd76a69d4087371da8ed42 /Git/Objects.hs
parentab1cf3570207bd08ae0abbba183a8c570c0361f5 (diff)
downloadgit-repair-efef527d5b2e42e261fa7af6947aad6553426ebe.tar.gz
Merge from git-annex.
Includes changing to new exceptions library, and some whitespace fixes.
Diffstat (limited to 'Git/Objects.hs')
-rw-r--r--Git/Objects.hs14
1 files changed, 14 insertions, 0 deletions
diff --git a/Git/Objects.hs b/Git/Objects.hs
index 516aa6d..dadd4f5 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
+ ]