handle case of adding populated drive to just created repo
The just created repo has no master branch commits yet. This is now handled, merging in the master branch from the populated drive.
This commit is contained in:
parent
a3f76fe696
commit
5ae1f75a39
5 changed files with 43 additions and 24 deletions
|
@ -23,13 +23,23 @@ import Git.Command
|
|||
-}
|
||||
current :: Repo -> IO (Maybe Git.Ref)
|
||||
current r = do
|
||||
branch <- firstLine <$> pipeRead [Param "symbolic-ref", Param "HEAD"] r
|
||||
if null branch
|
||||
then return Nothing
|
||||
else ifM (null <$> pipeRead [Param "show-ref", Param branch] r)
|
||||
( return Nothing
|
||||
, return $ Just $ Git.Ref branch
|
||||
)
|
||||
v <- currentUnsafe r
|
||||
case v of
|
||||
Nothing -> return Nothing
|
||||
Just branch ->
|
||||
ifM (null <$> pipeRead [Param "show-ref", Param $ show branch] r)
|
||||
( return Nothing
|
||||
, return v
|
||||
)
|
||||
|
||||
{- The current branch, which may not really exist yet. -}
|
||||
currentUnsafe :: Repo -> IO (Maybe Git.Ref)
|
||||
currentUnsafe r = parse . firstLine
|
||||
<$> pipeRead [Param "symbolic-ref", Param "HEAD"] r
|
||||
where
|
||||
parse l
|
||||
| null l = Nothing
|
||||
| otherwise = Just $ Git.Ref l
|
||||
|
||||
{- Checks if the second branch has any commits not present on the first
|
||||
- branch. -}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue