sync: Work even when the local git repository is new and empty, with no master branch.
This commit is contained in:
parent
43c47b6dbb
commit
bc18cde325
3 changed files with 20 additions and 14 deletions
|
@ -34,6 +34,5 @@ mergeBranch = do
|
||||||
|
|
||||||
mergeSynced :: CommandStart
|
mergeSynced :: CommandStart
|
||||||
mergeSynced = do
|
mergeSynced = do
|
||||||
branch <- inRepo Git.Branch.current
|
|
||||||
prepMerge
|
prepMerge
|
||||||
maybe stop mergeLocal branch
|
mergeLocal =<< inRepo Git.Branch.current
|
||||||
|
|
|
@ -45,12 +45,14 @@ seek rs = do
|
||||||
prepMerge
|
prepMerge
|
||||||
|
|
||||||
-- There may not be a branch checked out until after the commit,
|
-- There may not be a branch checked out until after the commit,
|
||||||
-- so only look it up once needed, and only look it up once.
|
-- or perhaps after it gets merged from the remote.
|
||||||
|
-- So only look it up once it's needed, and if once there is a
|
||||||
|
-- branch, cache it.
|
||||||
mvar <- liftIO newEmptyMVar
|
mvar <- liftIO newEmptyMVar
|
||||||
let getbranch = ifM (liftIO $ isEmptyMVar mvar)
|
let getbranch = ifM (liftIO $ isEmptyMVar mvar)
|
||||||
( do
|
( do
|
||||||
branch <- fromMaybe (error "no branch is checked out")
|
branch <- inRepo Git.Branch.current
|
||||||
<$> inRepo Git.Branch.current
|
when (isJust branch) $
|
||||||
liftIO $ putMVar mvar branch
|
liftIO $ putMVar mvar branch
|
||||||
return branch
|
return branch
|
||||||
, liftIO $ readMVar mvar
|
, liftIO $ readMVar mvar
|
||||||
|
@ -116,8 +118,9 @@ commit = next $ next $ ifM isDirect
|
||||||
_ <- inRepo $ tryIO . Git.Command.runQuiet params
|
_ <- inRepo $ tryIO . Git.Command.runQuiet params
|
||||||
return True
|
return True
|
||||||
|
|
||||||
mergeLocal :: Git.Ref -> CommandStart
|
mergeLocal :: Maybe Git.Ref -> CommandStart
|
||||||
mergeLocal branch = go =<< needmerge
|
mergeLocal Nothing = stop
|
||||||
|
mergeLocal (Just branch) = go =<< needmerge
|
||||||
where
|
where
|
||||||
syncbranch = syncBranch branch
|
syncbranch = syncBranch branch
|
||||||
needmerge = ifM isBareRepo
|
needmerge = ifM isBareRepo
|
||||||
|
@ -132,8 +135,9 @@ mergeLocal branch = go =<< needmerge
|
||||||
showStart "merge" $ Git.Ref.describe syncbranch
|
showStart "merge" $ Git.Ref.describe syncbranch
|
||||||
next $ next $ mergeFrom syncbranch
|
next $ next $ mergeFrom syncbranch
|
||||||
|
|
||||||
pushLocal :: Git.Ref -> CommandStart
|
pushLocal :: Maybe Git.Ref -> CommandStart
|
||||||
pushLocal branch = do
|
pushLocal Nothing = stop
|
||||||
|
pushLocal (Just branch) = do
|
||||||
inRepo $ updateBranch $ syncBranch branch
|
inRepo $ updateBranch $ syncBranch branch
|
||||||
stop
|
stop
|
||||||
|
|
||||||
|
@ -147,13 +151,13 @@ updateBranch syncbranch g =
|
||||||
, Param $ show $ Git.Ref.base syncbranch
|
, Param $ show $ Git.Ref.base syncbranch
|
||||||
] g
|
] g
|
||||||
|
|
||||||
pullRemote :: Remote -> Git.Ref -> CommandStart
|
pullRemote :: Remote -> Maybe Git.Ref -> CommandStart
|
||||||
pullRemote remote branch = do
|
pullRemote remote branch = do
|
||||||
showStart "pull" (Remote.name remote)
|
showStart "pull" (Remote.name remote)
|
||||||
next $ do
|
next $ do
|
||||||
showOutput
|
showOutput
|
||||||
stopUnless fetch $
|
stopUnless fetch $
|
||||||
next $ mergeRemote remote (Just branch)
|
next $ mergeRemote remote branch
|
||||||
where
|
where
|
||||||
fetch = inRepo $ Git.Command.runBool
|
fetch = inRepo $ Git.Command.runBool
|
||||||
[Param "fetch", Param $ Remote.name remote]
|
[Param "fetch", Param $ Remote.name remote]
|
||||||
|
@ -175,8 +179,9 @@ mergeRemote remote b = case b of
|
||||||
branchlist Nothing = []
|
branchlist Nothing = []
|
||||||
branchlist (Just branch) = [branch, syncBranch branch]
|
branchlist (Just branch) = [branch, syncBranch branch]
|
||||||
|
|
||||||
pushRemote :: Remote -> Git.Ref -> CommandStart
|
pushRemote :: Remote -> Maybe Git.Ref -> CommandStart
|
||||||
pushRemote remote branch = go =<< needpush
|
pushRemote _remote Nothing = stop
|
||||||
|
pushRemote remote (Just branch) = go =<< needpush
|
||||||
where
|
where
|
||||||
needpush = anyM (newer remote) [syncBranch branch, Annex.Branch.name]
|
needpush = anyM (newer remote) [syncBranch branch, Annex.Branch.name]
|
||||||
go False = stop
|
go False = stop
|
||||||
|
|
2
debian/changelog
vendored
2
debian/changelog
vendored
|
@ -2,6 +2,8 @@ git-annex (4.20131102) UNRELEASED; urgency=low
|
||||||
|
|
||||||
* Improve local pairing behavior when two computers both try to start
|
* Improve local pairing behavior when two computers both try to start
|
||||||
the pairing process separately.
|
the pairing process separately.
|
||||||
|
* sync: Work even when the local git repository is new and empty,
|
||||||
|
with no master branch.
|
||||||
|
|
||||||
-- Joey Hess <joeyh@debian.org> Sat, 02 Nov 2013 14:54:36 -0400
|
-- Joey Hess <joeyh@debian.org> Sat, 02 Nov 2013 14:54:36 -0400
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue