cleanup
This commit is contained in:
parent
acd7a52dfd
commit
2332afb4bc
2 changed files with 17 additions and 15 deletions
|
@ -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
|
||||
|
|
|
@ -40,6 +40,10 @@ separate c l = unbreak $ break c l
|
|||
| null b = r
|
||||
| otherwise = (a, tail b)
|
||||
|
||||
{- Breaks out the first line. -}
|
||||
firstLine :: String-> String
|
||||
firstLine = takeWhile (/= '\n')
|
||||
|
||||
{- Catches IO errors and returns a Bool -}
|
||||
catchBoolIO :: IO Bool -> IO Bool
|
||||
catchBoolIO a = catchDefaultIO a False
|
||||
|
|
Loading…
Reference in a new issue