From a31b7d93c85afde1e801748b6a7cf5372492bee8 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 30 Dec 2011 19:38:46 -0400 Subject: [PATCH] push when git-annex branch changed I was too heavy-handed in optimising away pushes --- Command/Sync.hs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Command/Sync.hs b/Command/Sync.hs index 4b11e3ac11..a3450278ce 100644 --- a/Command/Sync.hs +++ b/Command/Sync.hs @@ -129,12 +129,16 @@ mergeRemote remote branch = all (== True) <$> mapM go [branch, syncBranch branch remotebranch = Git.Ref.under $ "refs/remotes/" ++ Remote.name remote pushRemote :: Remote.Remote Annex -> Git.Ref -> CommandStart -pushRemote remote branch = go =<< newer +pushRemote remote branch = go =<< needpush where - newer = do - e <- inRepo (Git.Ref.exists syncbranchRemote) + needpush = (||) + <$> newer syncbranch + <*> newer Annex.Branch.name + newer b = do + let r = remotebranch b + e <- inRepo (Git.Ref.exists r) if e - then inRepo $ Git.Branch.changed syncbranchRemote syncbranch + then inRepo $ Git.Branch.changed r b else return True go False = stop go True = do @@ -148,8 +152,7 @@ pushRemote remote branch = go =<< newer ] refspec = show (Git.Ref.base branch) ++ ":" ++ show (Git.Ref.base syncbranch) syncbranch = syncBranch branch - syncbranchRemote = Git.Ref.under - ("refs/remotes/" ++ Remote.name remote) syncbranch + remotebranch = Git.Ref.under $ "refs/remotes/" ++ Remote.name remote currentBranch :: Annex Git.Ref currentBranch = Git.Ref . firstLine . L.unpack <$>