summaryrefslogtreecommitdiff
path: root/Command
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-08-05 16:35:30 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-08-05 16:35:30 -0400
commit5ae1f75a39ffd26b23c8199998f502df78b9b75a (patch)
tree5ba650b428cd90b98a0380bed37df59efd3294a9 /Command
parenta3f76fe696c603078621ccca6d7b17270cc7ef11 (diff)
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.
Diffstat (limited to 'Command')
-rw-r--r--Command/Sync.hs14
1 files changed, 10 insertions, 4 deletions
diff --git a/Command/Sync.hs b/Command/Sync.hs
index 7bf3048de..ab29c82b6 100644
--- a/Command/Sync.hs
+++ b/Command/Sync.hs
@@ -123,7 +123,7 @@ pullRemote remote branch = do
next $ do
showOutput
stopUnless fetch $
- next $ mergeRemote remote branch
+ next $ mergeRemote remote (Just branch)
where
fetch = inRepo $ Git.Command.runBool "fetch"
[Param $ Remote.name remote]
@@ -132,11 +132,17 @@ pullRemote remote branch = do
- Which to merge from? Well, the master has whatever latest changes
- were committed, while the synced/master may have changes that some
- other remote synced to this remote. So, merge them both. -}
-mergeRemote :: Remote -> Git.Ref -> CommandCleanup
-mergeRemote remote branch = all id <$> (mapM merge =<< tomerge)
+mergeRemote :: Remote -> (Maybe Git.Ref) -> CommandCleanup
+mergeRemote remote b = case b of
+ Nothing -> do
+ branch <- inRepo Git.Branch.currentUnsafe
+ all id <$> (mapM merge $ branchlist branch)
+ Just _ -> all id <$> (mapM merge =<< tomerge (branchlist b))
where
merge = mergeFrom . remoteBranch remote
- tomerge = filterM (changed remote) [branch, syncBranch branch]
+ tomerge branches = filterM (changed remote) branches
+ branchlist Nothing = []
+ branchlist (Just branch) = [branch, syncBranch branch]
pushRemote :: Remote -> Git.Ref -> CommandStart
pushRemote remote branch = go =<< needpush