summaryrefslogtreecommitdiff
path: root/Git/Objects.hs
diff options
context:
space:
mode:
authorJoey Hess <joey@kitenet.net>2013-11-20 18:31:00 -0400
committerJoey Hess <joey@kitenet.net>2013-11-20 18:31:00 -0400
commit7dbb702edd43b4ff3148f13c8e28634931ba54cd (patch)
tree71c156db9fa3f4347ed6dd2cf32cd42c36eb08d5 /Git/Objects.hs
parenta1f8621efc3706763e9d163fb778781a678dca99 (diff)
merge from git-repair
Diffstat (limited to 'Git/Objects.hs')
-rw-r--r--Git/Objects.hs10
1 files changed, 8 insertions, 2 deletions
diff --git a/Git/Objects.hs b/Git/Objects.hs
index b1c5805332..d9d2c67018 100644
--- a/Git/Objects.hs
+++ b/Git/Objects.hs
@@ -9,6 +9,7 @@ module Git.Objects where
import Common
import Git
+import Git.Sha
objectsDir :: Repo -> FilePath
objectsDir r = localGitDir r </> "objects"
@@ -16,12 +17,17 @@ objectsDir r = localGitDir r </> "objects"
packDir :: Repo -> FilePath
packDir r = objectsDir r </> "pack"
+packIdxFile :: FilePath -> FilePath
+packIdxFile = flip replaceExtension "idx"
+
listPackFiles :: Repo -> IO [FilePath]
listPackFiles r = filter (".pack" `isSuffixOf`)
<$> catchDefaultIO [] (dirContents $ packDir r)
-packIdxFile :: FilePath -> FilePath
-packIdxFile = flip replaceExtension "idx"
+listLooseObjectShas :: Repo -> IO [Sha]
+listLooseObjectShas r = catchDefaultIO [] $
+ mapMaybe (extractSha . concat . reverse . take 2 . reverse . splitDirectories)
+ <$> dirContentsRecursiveSkipping (== "pack") (objectsDir r)
looseObjectFile :: Repo -> Sha -> FilePath
looseObjectFile r sha = objectsDir r </> prefix </> rest