diff options
author | Joey Hess <joey@kitenet.net> | 2013-04-30 16:35:55 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2013-04-30 16:37:13 -0400 |
commit | 31b9d2dcd1b32f564fa44fe5a7cc6526536a6f8f (patch) | |
tree | 0ea87a6208459f73f74f593e42aabd7fc25ed832 | |
parent | baec0e627d5ea31131729274415041c01de2bcf0 (diff) |
assistant: Fix bug that could cause incoming pushes to not get merged into the local tree.
Observed that the pushed refs were received, but not merged into master.
The merger never saw an add event for these refs. Either git is not writing
to a new file and renaming it into place, or the inotify code didn't notice
that. Changed it to also watch for modify events and that seems to have
fixed it!
-rw-r--r-- | Assistant/Threads/Merger.hs | 18 | ||||
-rw-r--r-- | debian/changelog | 2 |
2 files changed, 9 insertions, 11 deletions
diff --git a/Assistant/Threads/Merger.hs b/Assistant/Threads/Merger.hs index a1b1693cf..650293e4b 100644 --- a/Assistant/Threads/Merger.hs +++ b/Assistant/Threads/Merger.hs @@ -32,10 +32,11 @@ mergeThread = namedThread "Merger" $ do let dir = Git.localGitDir g </> "refs" liftIO $ createDirectoryIfMissing True dir let hook a = Just <$> asIO2 (runHandler a) - addhook <- hook onAdd + changehook <- hook onChange errhook <- hook onErr let hooks = mkWatchHooks - { addHook = addhook + { addHook = changehook + , modifyHook = changehook , errHook = errhook } void $ liftIO $ watchDir dir (const False) hooks id @@ -55,19 +56,14 @@ runHandler handler file _filestatus = onErr :: Handler onErr msg = error msg -{- Called when a new branch ref is written. - - - - This relies on git's atomic method of updating branch ref files, - - which is to first write the new file to .lock, and then rename it - - over the old file. So, ignore .lock files, and the rename ensures - - the watcher sees a new file being added on each update. +{- Called when a new branch ref is written, or a branch ref is modified. - - At startup, synthetic add events fire, causing this to run, but that's - ok; it ensures that any changes pushed since the last time the assistant - ran are merged in. -} -onAdd :: Handler -onAdd file +onChange :: Handler +onChange file | ".lock" `isSuffixOf` file = noop | isAnnexBranch file = do branchChanged @@ -75,7 +71,7 @@ onAdd file when diverged $ unlessM handleDesynced $ queueDeferredDownloads "retrying deferred download" Later - | "/synced/" `isInfixOf` file = do + | "/synced/" `isInfixOf` file = mergecurrent =<< liftAnnex (inRepo Git.Branch.current) | otherwise = noop where diff --git a/debian/changelog b/debian/changelog index d3b520424..47ff23bf9 100644 --- a/debian/changelog +++ b/debian/changelog @@ -53,6 +53,8 @@ git-annex (4.20130418) UNRELEASED; urgency=low when you or the friend have multiple reposotories on an XMPP account. Note that XMPP pairing with your own devices still pairs with all repositories using your XMPP account. + * assistant: Fix bug that could cause incoming pushes to not get + merged into the local tree. -- Joey Hess <joeyh@debian.org> Thu, 18 Apr 2013 16:22:48 -0400 |