summaryrefslogtreecommitdiff
path: root/Git/Objects.hs
diff options
context:
space:
mode:
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 b1c5805..d9d2c67 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