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 Nothing = return ()
|
||||||
go (Just branchref) = do
|
go (Just branchref) = do
|
||||||
lock <- fromRepo gitAnnexIndexLock
|
lock <- fromRepo gitAnnexIndexLock
|
||||||
lockref <- firstRef <$> liftIO (catchDefaultIO (readFileStrict lock) "")
|
lockref <- Git.Ref . firstLine <$>
|
||||||
|
liftIO (catchDefaultIO (readFileStrict lock) "")
|
||||||
when (lockref /= branchref) $ do
|
when (lockref /= branchref) $ do
|
||||||
withIndex $ mergeIndex [fullname]
|
withIndex $ mergeIndex [fullname]
|
||||||
setIndexRef branchref
|
setIndexRef branchref
|
||||||
|
@ -303,6 +304,17 @@ refExists :: Git.Ref -> Annex Bool
|
||||||
refExists ref = inRepo $ Git.runBool "show-ref"
|
refExists ref = inRepo $ Git.runBool "show-ref"
|
||||||
[Param "--verify", Param "-q", Param $ 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? -}
|
{- Does the main git-annex branch exist? -}
|
||||||
hasBranch :: Annex Bool
|
hasBranch :: Annex Bool
|
||||||
hasBranch = refExists fullname
|
hasBranch = refExists fullname
|
||||||
|
@ -325,20 +337,6 @@ siblingBranches = do
|
||||||
gen l = (Git.Ref $ head l, Git.Ref $ last l)
|
gen l = (Git.Ref $ head l, Git.Ref $ last l)
|
||||||
uref (a, _) (b, _) = a == b
|
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.
|
{- Applies a function to modifiy the content of a file.
|
||||||
-
|
-
|
||||||
- Note that this does not cause the branch to be merged, it only
|
- 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
|
| null b = r
|
||||||
| otherwise = (a, tail b)
|
| otherwise = (a, tail b)
|
||||||
|
|
||||||
|
{- Breaks out the first line. -}
|
||||||
|
firstLine :: String-> String
|
||||||
|
firstLine = takeWhile (/= '\n')
|
||||||
|
|
||||||
{- Catches IO errors and returns a Bool -}
|
{- Catches IO errors and returns a Bool -}
|
||||||
catchBoolIO :: IO Bool -> IO Bool
|
catchBoolIO :: IO Bool -> IO Bool
|
||||||
catchBoolIO a = catchDefaultIO a False
|
catchBoolIO a = catchDefaultIO a False
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue