From e1447dc2e264b929a99d4ab34623f09de6c5e3fd Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 7 May 2024 14:22:41 -0400 Subject: [PATCH] add git bundle interface Sponsored-by: mycroft on Patreon --- Git/Bundle.hs | 25 +++++++++++++++++++++++++ git-annex.cabal | 1 + 2 files changed, 26 insertions(+) create mode 100644 Git/Bundle.hs diff --git a/Git/Bundle.hs b/Git/Bundle.hs new file mode 100644 index 0000000000..7b1b1adc15 --- /dev/null +++ b/Git/Bundle.hs @@ -0,0 +1,25 @@ +{- git bundles + - + - Copyright 2024 Joey Hess + - + - Licensed under the GNU AGPL version 3 or higher. + -} + +module Git.Bundle where + +import Common +import Git +import Git.Command + +import Data.Char (ord) +import qualified Data.ByteString.Char8 as S8 + +listHeads :: FilePath -> Repo -> IO [(Sha, Ref)] +listHeads bundle repo = map gen . S8.lines <$> + pipeReadStrict [Param "bundle", Param "list-heads", File bundle] repo + where + gen l = let (s, r) = separate' (== fromIntegral (ord ' ')) l + in (Ref s, Ref r) + +unbundle :: FilePath -> Repo -> IO () +unbundle bundle = runQuiet [Param "bundle", Param "unbundle", File bundle] diff --git a/git-annex.cabal b/git-annex.cabal index 3c6ad98118..53f9d5d786 100644 --- a/git-annex.cabal +++ b/git-annex.cabal @@ -760,6 +760,7 @@ Executable git-annex Git.AutoCorrect Git.Branch Git.BuildVersion + Git.Bundle Git.CatFile Git.CheckAttr Git.CheckIgnore