From 2332afb4bc207ab04b4a1d7adfb3a2df7f5d7874 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 12 Dec 2011 02:04:48 -0400 Subject: cleanup --- Annex/Branch.hs | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'Annex') diff --git a/Annex/Branch.hs b/Annex/Branch.hs index 3da8bb198..b108281ce 100644 --- a/Annex/Branch.hs +++ b/Annex/Branch.hs @@ -88,7 +88,8 @@ updateIndex = do go Nothing = return () go (Just branchref) = do lock <- fromRepo gitAnnexIndexLock - lockref <- firstRef <$> liftIO (catchDefaultIO (readFileStrict lock) "") + lockref <- Git.Ref . firstLine <$> + liftIO (catchDefaultIO (readFileStrict lock) "") when (lockref /= branchref) $ do withIndex $ mergeIndex [fullname] setIndexRef branchref @@ -303,6 +304,17 @@ refExists :: Git.Ref -> Annex Bool refExists ref = inRepo $ Git.runBool "show-ref" [Param "--verify", Param "-q", Param $ show ref] +{- Get the ref of a branch. -} +getRef :: Git.Branch -> Annex (Maybe Git.Ref) +getRef branch = process . L.unpack <$> showref + where + showref = inRepo $ Git.pipeRead [Param "show-ref", + Param "--hash", -- get the hash + Params "--verify", -- only exact match + Param $ show branch] + process [] = Nothing + process s = Just $ Git.Ref $ firstLine s + {- Does the main git-annex branch exist? -} hasBranch :: Annex Bool hasBranch = refExists fullname @@ -325,20 +337,6 @@ siblingBranches = do gen l = (Git.Ref $ head l, Git.Ref $ last l) uref (a, _) (b, _) = a == b -{- Get the ref of a branch. -} -getRef :: Git.Ref -> Annex (Maybe Git.Ref) -getRef branch = process . L.unpack <$> showref - where - showref = inRepo $ Git.pipeRead [Param "show-ref", - Param "--hash", -- get the hash - Params "--verify", -- only exact match - Param $ show branch] - process [] = Nothing - process s = Just $ firstRef s - -firstRef :: String-> Git.Ref -firstRef = Git.Ref . takeWhile (/= '\n') - {- Applies a function to modifiy the content of a file. - - Note that this does not cause the branch to be merged, it only -- cgit v1.2.3