enableremote: Remove annex-ignore configuration from a remote.

This commit is contained in:
Joey Hess 2016-05-24 15:48:22 -04:00
parent b33a649a25
commit 1b3bde0625
Failed to extract signature
5 changed files with 34 additions and 17 deletions

View file

@ -22,6 +22,7 @@ git-annex (6.20160512) UNRELEASED; urgency=medium
* enableremote: Can now be used to explicitly enable git-annex to use * enableremote: Can now be used to explicitly enable git-annex to use
git remotes. Using the command this way prevents other git-annex git remotes. Using the command this way prevents other git-annex
commands from probing new git remotes to auto-enable them. commands from probing new git remotes to auto-enable them.
* enableremote: Remove annex-ignore configuration from a remote.
* Support building with ghc 8.0.1. * Support building with ghc 8.0.1.
* Pass the various gnupg-options configs to gpg in several cases where * Pass the various gnupg-options configs to gpg in several cases where
they were not before. Most notably, gnupg-decrypt-options is now they were not before. Most notably, gnupg-decrypt-options is now

View file

@ -11,13 +11,14 @@ import Command
import qualified Annex import qualified Annex
import qualified Logs.Remote import qualified Logs.Remote
import qualified Types.Remote as R import qualified Types.Remote as R
import qualified Git.Types as Git import qualified Git
import qualified Annex.SpecialRemote import qualified Annex.SpecialRemote
import qualified Remote import qualified Remote
import qualified Types.Remote as Remote import qualified Types.Remote as Remote
import qualified Remote.Git import qualified Remote.Git
import Logs.UUID import Logs.UUID
import Annex.UUID import Annex.UUID
import Config
import qualified Data.Map as M import qualified Data.Map as M
@ -45,9 +46,10 @@ startNormalRemote :: RemoteName -> Git.Repo -> CommandStart
startNormalRemote name r = do startNormalRemote name r = do
showStart "enableremote" name showStart "enableremote" name
next $ next $ do next $ next $ do
setRemoteIgnore r False
r' <- Remote.Git.configRead False r r' <- Remote.Git.configRead False r
u <- getRepoUUID r' u <- getRepoUUID r'
return (u /= NoUUID) return $ u /= NoUUID
startSpecialRemote :: RemoteName -> Remote.RemoteConfig -> Maybe (UUID, Remote.RemoteConfig) -> CommandStart startSpecialRemote :: RemoteName -> Remote.RemoteConfig -> Maybe (UUID, Remote.RemoteConfig) -> CommandStart
startSpecialRemote name config Nothing = do startSpecialRemote name config Nothing = do
@ -74,6 +76,10 @@ performSpecialRemote t u c gc = do
cleanupSpecialRemote :: UUID -> R.RemoteConfig -> CommandCleanup cleanupSpecialRemote :: UUID -> R.RemoteConfig -> CommandCleanup
cleanupSpecialRemote u c = do cleanupSpecialRemote u c = do
Logs.Remote.configSet u c Logs.Remote.configSet u c
mr <- Remote.byUUID u
case mr of
Nothing -> noop
Just r -> setRemoteIgnore (R.repo r) False
return True return True
unknownNameError :: String -> Annex a unknownNameError :: String -> Annex a
@ -85,8 +91,12 @@ unknownNameError prefix = do
else Remote.prettyPrintUUIDsDescs else Remote.prettyPrintUUIDsDescs
"known special remotes" "known special remotes"
descm (M.keys m) descm (M.keys m)
nouuids <- filterM (\r -> (==) NoUUID <$> getRepoUUID r) disabledremotes <- filterM isdisabled =<< Annex.fromRepo Git.remotes
=<< Annex.fromRepo Git.remotes let remotesmsg = unlines $ map ("\t" ++) $
let nouuidmsg = unlines $ map ("\t" ++) $ mapMaybe Git.remoteName disabledremotes
mapMaybe Git.remoteName nouuids error $ concat $ filter (not . null) [prefix ++ "\n", remotesmsg, specialmsg]
error $ concat $ filter (not . null) [prefix ++ "\n", nouuidmsg, specialmsg] where
isdisabled r = anyM id
[ (==) NoUUID <$> getRepoUUID r
, remoteAnnexIgnore <$> Annex.getRemoteGitConfig r
]

View file

@ -80,6 +80,12 @@ setRemoteCost r c = setConfig (remoteConfig r "cost") (show c)
setRemoteAvailability :: Git.Repo -> Availability -> Annex () setRemoteAvailability :: Git.Repo -> Availability -> Annex ()
setRemoteAvailability r c = setConfig (remoteConfig r "availability") (show c) setRemoteAvailability r c = setConfig (remoteConfig r "availability") (show c)
setRemoteIgnore :: Git.Repo -> Bool -> Annex ()
setRemoteIgnore r b = setConfig (remoteConfig r "ignore") (Git.Config.boolConfig b)
setRemoteBare :: Git.Repo -> Bool -> Annex ()
setRemoteBare r b = setConfig (remoteConfig r "bare") (Git.Config.boolConfig b)
isDirect :: Annex Bool isDirect :: Annex Bool
isDirect = annexDirect <$> Annex.getGitConfig isDirect = annexDirect <$> Annex.getGitConfig

View file

@ -247,7 +247,7 @@ tryGitConfigRead autoinit r
-- Cache when http remote is not bare for -- Cache when http remote is not bare for
-- optimisation. -- optimisation.
unless (Git.Config.isBare r') $ unless (Git.Config.isBare r') $
setremote "annex-bare" (Git.Config.boolConfig False) setremote setRemoteBare False
return r' return r'
store = observe $ \r' -> do store = observe $ \r' -> do
@ -274,21 +274,18 @@ tryGitConfigRead autoinit r
return r return r
set_ignore msg longmessage = do set_ignore msg longmessage = do
let k = "annex-ignore"
case Git.remoteName r of case Git.remoteName r of
Nothing -> noop Nothing -> noop
Just n -> do Just n -> do
warning $ "Remote " ++ n ++ " " ++ msg ++ "; setting " ++ k warning $ "Remote " ++ n ++ " " ++ msg ++ "; setting annex-ignore"
when longmessage $ when longmessage $
warning $ "This could be a problem with the git-annex installation on the remote. Please make sure that git-annex-shell is available in PATH when you ssh into the remote. Once you have fixed the git-annex installation, run: git config remote." ++ n ++ "." ++ k ++ " false" warning $ "This could be a problem with the git-annex installation on the remote. Please make sure that git-annex-shell is available in PATH when you ssh into the remote. Once you have fixed the git-annex installation, run: git annex enableremote " ++ n
setremote k (Git.Config.boolConfig True) setremote setRemoteIgnore True
setremote k v = case Git.remoteName r of setremote setter v = case Git.remoteName r of
Nothing -> noop Nothing -> noop
Just n -> do Just n -> setter r v
let k' = "remote." ++ n ++ "." ++ k
inRepo $ Git.Command.run [Param "config", Param k', Param v]
handlegcrypt Nothing = return r handlegcrypt Nothing = return r
handlegcrypt (Just _cacheduuid) = do handlegcrypt (Just _cacheduuid) = do
-- Generate UUID from the gcrypt-id -- Generate UUID from the gcrypt-id

View file

@ -59,6 +59,9 @@ a new clone, it will will attempt to enable the special remote. Of course,
this works best when the special remote does not need anything special this works best when the special remote does not need anything special
to be done to get it enabled. to be done to get it enabled.
(This command also can be used to enable a remote that git-annex has been
prevented from using by the `remote.<name>.annex-ignore` setting.)
# SEE ALSO # SEE ALSO
[[git-annex]](1) [[git-annex]](1)