diff options
author | Joey Hess <joeyh@joeyh.name> | 2015-08-05 13:49:54 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2015-08-05 13:49:58 -0400 |
commit | a43686b9847c19efebd1f15519083436ac155a8e (patch) | |
tree | 98abed3386788da3002142a1053cdce09789c023 /Remote/Git.hs | |
parent | 0ad42412dbc981969e0847b498701e6b9ca6dd17 (diff) |
Simplify setup process for a ssh remote.
Now it suffices to run git remote add, followed by git-annex sync. Now the
remote is automatically initialized for use by git-annex, where before the
git-annex branch had to manually be pushed before using git-annex sync.
Note that this involved changes to git-annex-shell, so if the remote is
using an old version, the manual push is still needed.
Implementation required git-annex-shell be changed, so configlist can
autoinit a repository even when no git-annex branch has been pushed yet.
Unfortunate because we'll have to wait for it to get deployed to servers
before being able to rely on this change in the documentation.
Did consider making git-annex sync push the git-annex branch to repos that
didn't have a uuid, but this seemed difficult to do without complicating it
in messy ways.
It would be cleaner to split a command out from configlist to handle
the initialization. But this is difficult without sacrificing backwards
compatability, for users of old git-annex versions which would not use the
new command.
Diffstat (limited to 'Remote/Git.hs')
-rw-r--r-- | Remote/Git.hs | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/Remote/Git.hs b/Remote/Git.hs index 5ac79df6d..4505c14ff 100644 --- a/Remote/Git.hs +++ b/Remote/Git.hs @@ -67,11 +67,11 @@ remote = RemoteType { setup = gitSetup } -list :: Annex [Git.Repo] -list = do +list :: Bool -> Annex [Git.Repo] +list autoinit = do c <- fromRepo Git.config rs <- mapM (tweakurl c) =<< fromRepo Git.remotes - mapM configRead rs + mapM (configRead autoinit) rs where annexurl n = "remote." ++ n ++ ".annexurl" tweakurl c r = do @@ -116,14 +116,14 @@ gitSetup (Just u) _ c = do - - Conversely, the config of an URL remote is only read when there is no - cached UUID value. -} -configRead :: Git.Repo -> Annex Git.Repo -configRead r = do +configRead :: Bool -> Git.Repo -> Annex Git.Repo +configRead autoinit r = do gc <- Annex.getRemoteGitConfig r u <- getRepoUUID r case (repoCheap r, remoteAnnexIgnore gc, u) of (_, True, _) -> return r - (True, _, _) -> tryGitConfigRead r - (False, _, NoUUID) -> tryGitConfigRead r + (True, _, _) -> tryGitConfigRead autoinit r + (False, _, NoUUID) -> tryGitConfigRead autoinit r _ -> return r gen :: Git.Repo -> UUID -> RemoteConfig -> RemoteGitConfig -> Annex (Maybe Remote) @@ -196,11 +196,12 @@ repoAvail r {- Tries to read the config for a specified remote, updates state, and - returns the updated repo. -} -tryGitConfigRead :: Git.Repo -> Annex Git.Repo -tryGitConfigRead r +tryGitConfigRead :: Bool -> Git.Repo -> Annex Git.Repo +tryGitConfigRead autoinit r | haveconfig r = return r -- already read | Git.repoIsSsh r = store $ do - v <- Ssh.onRemote r (pipedconfig, return (Left $ error "configlist failed")) "configlist" [] [] + liftIO $ print autoinit + v <- Ssh.onRemote r (pipedconfig, return (Left $ error "configlist failed")) "configlist" [] configlistfields case v of Right r' | haveconfig r' -> return r' @@ -302,6 +303,10 @@ tryGitConfigRead r Annex.BranchState.disableUpdate void $ tryNonAsync $ ensureInitialized Annex.getState Annex.repo + + configlistfields = if autoinit + then [(Fields.autoInit, "1")] + else [] {- Checks if a given remote has the content for a key in its annex. -} inAnnex :: Remote -> Key -> Annex Bool |