diff options
author | Joey Hess <joey@kitenet.net> | 2013-10-20 17:50:51 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2013-10-20 17:50:51 -0400 |
commit | 66ccc37a99994f1206d308c0c0003ac2605d3c42 (patch) | |
tree | 17fd97ca91a7c963cf80ac1274c94ac841e8572c /Git/Objects.hs | |
parent | 66e2c6e3a16480e25f82ef447cfebac16997aac5 (diff) |
git-recover-repository 1/2 done
Diffstat (limited to 'Git/Objects.hs')
-rw-r--r-- | Git/Objects.hs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/Git/Objects.hs b/Git/Objects.hs new file mode 100644 index 000000000..b1c580533 --- /dev/null +++ b/Git/Objects.hs @@ -0,0 +1,29 @@ +{- .git/objects + - + - Copyright 2013 Joey Hess <joey@kitenet.net> + - + - Licensed under the GNU GPL version 3 or higher. + -} + +module Git.Objects where + +import Common +import Git + +objectsDir :: Repo -> FilePath +objectsDir r = localGitDir r </> "objects" + +packDir :: Repo -> FilePath +packDir r = objectsDir r </> "pack" + +listPackFiles :: Repo -> IO [FilePath] +listPackFiles r = filter (".pack" `isSuffixOf`) + <$> catchDefaultIO [] (dirContents $ packDir r) + +packIdxFile :: FilePath -> FilePath +packIdxFile = flip replaceExtension "idx" + +looseObjectFile :: Repo -> Sha -> FilePath +looseObjectFile r sha = objectsDir r </> prefix </> rest + where + (prefix, rest) = splitAt 2 (show sha) |