diff options
author | Joey Hess <joey@kitenet.net> | 2014-07-15 14:27:43 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2014-07-15 14:27:43 -0400 |
commit | c94a5d86b80dd06a018689da551012bf7d608dec (patch) | |
tree | 1616e477ff19d38a45e09258eb4facba11b9f895 | |
parent | b5d944968aee1390bbcbcb36f96e26d8a0a5c9dd (diff) |
sync: Fix git sync with local git remotes even when they don't have an annex.uuid set.
Catch an exception when ensureInitialized is run in a non-initted
repository. In this case, just read the git config, so that the Git.Repo
object is not LocalUnknown, which is what is used to represent remotes
on eg, drives that are not connected.
The assistant already got this right, and like with the assistant, this
causes an implicit git-annex init of the local remote on the second sync,
once the git-annex branch has been pushed to it.
See this comment for more analysis:
http://git-annex.branchable.com/todo/Recovering_from_a_bad_sync/#comment-64e469a2c1969829ee149cbb41b1c138
This commit was sponsored by jscit.
-rw-r--r-- | Remote/Git.hs | 22 | ||||
-rw-r--r-- | debian/changelog | 2 | ||||
-rw-r--r-- | doc/git-annex.mdwn | 8 | ||||
-rw-r--r-- | doc/todo/Recovering_from_a_bad_sync.mdwn | 2 |
4 files changed, 19 insertions, 15 deletions
diff --git a/Remote/Git.hs b/Remote/Git.hs index 5dcd3bf15..6308f5cd6 100644 --- a/Remote/Git.hs +++ b/Remote/Git.hs @@ -191,20 +191,11 @@ tryGitConfigRead r | Git.repoIsHttp r = store geturlconfig | Git.GCrypt.isEncrypted r = handlegcrypt =<< getConfigMaybe (remoteConfig r "uuid") | Git.repoIsUrl r = return r - | otherwise = store $ safely $ do - s <- Annex.new r - Annex.eval s $ do - Annex.BranchState.disableUpdate - ensureInitialized - Annex.getState Annex.repo + | otherwise = store $ liftIO $ + readlocalannexconfig `catchNonAsync` (const $ Git.Config.read r) where haveconfig = not . M.null . Git.config - -- Reading config can fail due to IO error or - -- for other reasons; catch all possible exceptions. - safely a = either (const $ return r) return - =<< liftIO (try a :: IO (Either SomeException Git.Repo)) - pipedconfig cmd params = do v <- Git.Config.fromPipe r cmd params case v of @@ -283,6 +274,15 @@ tryGitConfigRead r Just v -> store $ liftIO $ setUUID r $ genUUIDInNameSpace gCryptNameSpace v + {- Throws an exception if the remote is not already initialied + - or cannot be automatically initialized. -} + readlocalannexconfig = do + s <- Annex.new r + Annex.eval s $ do + Annex.BranchState.disableUpdate + ensureInitialized + Annex.getState Annex.repo + {- Checks if a given remote has the content for a key inAnnex. - If the remote cannot be accessed, or if it cannot determine - whether it has the content, returns a Left error message. diff --git a/debian/changelog b/debian/changelog index 5cefc2888..179a24dca 100644 --- a/debian/changelog +++ b/debian/changelog @@ -15,6 +15,8 @@ git-annex (5.20140710) UNRELEASED; urgency=medium resolution leave behind old files. * Windows: Fix locking issue that prevented the webapp starting (since 5.20140707). + * sync: Fix git sync with local git remotes even when they don't have an + annex.uuid set. (The assistant already did so.) -- Joey Hess <joeyh@debian.org> Wed, 09 Jul 2014 23:29:21 -0400 diff --git a/doc/git-annex.mdwn b/doc/git-annex.mdwn index 2d114e7ff..8ba3558d3 100644 --- a/doc/git-annex.mdwn +++ b/doc/git-annex.mdwn @@ -139,10 +139,10 @@ subdirectories). * `sync [remote ...]` Use this command when you want to synchronize the local repository with - one or more of its remotes. You can specify the remotes to sync with; - the default is to sync with all remotes that have an annex.uuid - configured. Or specify `--fast` to sync with the remotes with the - lowest annex-cost value. Or specify the remotes to sync with. + one or more of its remotes. You can specify the remotes to sync with by + name; the default is to sync with all remotes. + Or specify `--fast` to sync with the remotes with the + lowest annex-cost value. The sync process involves first committing all local changes, then fetching and merging the `synced/master` and the `git-annex` branch diff --git a/doc/todo/Recovering_from_a_bad_sync.mdwn b/doc/todo/Recovering_from_a_bad_sync.mdwn index 4b7ca672c..d60406568 100644 --- a/doc/todo/Recovering_from_a_bad_sync.mdwn +++ b/doc/todo/Recovering_from_a_bad_sync.mdwn @@ -27,3 +27,5 @@ These sequences of commands create two completely different git histories. More important, if one clones on pc2 the first repository, they will see both the pc1 remote and the pc2 remote. Instead, if one clones on pc2 the repository created by the second combination of commands, they will see only the pc2 remote. What commands should I use on pc1 to fix the history so that when pc2 clones from the origin repository it will see both the pc1 remote and its own local remote? + +> [[done]]; fixed per my comments. --[[Joey]] |