summaryrefslogtreecommitdiff
path: root/Annex
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-12-12 02:04:48 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-12-12 02:04:48 -0400
commit2332afb4bc207ab04b4a1d7adfb3a2df7f5d7874 (patch)
tree296ee7c5e281ed231cba4ca3fe0dbd9f5c2f5e51 /Annex
parentacd7a52dfd2cad24fd946ffcf8c4b1d07eb474ce (diff)
cleanup
Diffstat (limited to 'Annex')
-rw-r--r--Annex/Branch.hs28
1 files changed, 13 insertions, 15 deletions
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