summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2016-05-24 15:48:22 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2016-05-24 15:58:27 -0400
commit475d3dbf61a111e7ad7edfbc53df9af60b62bdb5 (patch)
tree08f8a5aa9a0f7d7f80b835c3bf6bb0f262697bcb
parentba3bc0d631702ce91f1044985f2c3f533fb4f95d (diff)
enableremote: Remove annex-ignore configuration from a remote.
-rw-r--r--CHANGELOG1
-rw-r--r--Command/EnableRemote.hs24
-rw-r--r--Config.hs6
-rw-r--r--Remote/Git.hs17
-rw-r--r--doc/git-annex-enableremote.mdwn3
5 files changed, 34 insertions, 17 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 8a4058573..e58c6eeda 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -22,6 +22,7 @@ git-annex (6.20160512) UNRELEASED; urgency=medium
* enableremote: Can now be used to explicitly enable git-annex to use
git remotes. Using the command this way prevents other git-annex
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.
* Pass the various gnupg-options configs to gpg in several cases where
they were not before. Most notably, gnupg-decrypt-options is now
diff --git a/Command/EnableRemote.hs b/Command/EnableRemote.hs
index bf0ad37a3..dc3e7bc56 100644
--- a/Command/EnableRemote.hs
+++ b/Command/EnableRemote.hs
@@ -11,13 +11,14 @@ import Command
import qualified Annex
import qualified Logs.Remote
import qualified Types.Remote as R
-import qualified Git.Types as Git
+import qualified Git
import qualified Annex.SpecialRemote
import qualified Remote
import qualified Types.Remote as Remote
import qualified Remote.Git
import Logs.UUID
import Annex.UUID
+import Config
import qualified Data.Map as M
@@ -45,9 +46,10 @@ startNormalRemote :: RemoteName -> Git.Repo -> CommandStart
startNormalRemote name r = do
showStart "enableremote" name
next $ next $ do
+ setRemoteIgnore r False
r' <- Remote.Git.configRead False r
u <- getRepoUUID r'
- return (u /= NoUUID)
+ return $ u /= NoUUID
startSpecialRemote :: RemoteName -> Remote.RemoteConfig -> Maybe (UUID, Remote.RemoteConfig) -> CommandStart
startSpecialRemote name config Nothing = do
@@ -74,6 +76,10 @@ performSpecialRemote t u c gc = do
cleanupSpecialRemote :: UUID -> R.RemoteConfig -> CommandCleanup
cleanupSpecialRemote u c = do
Logs.Remote.configSet u c
+ mr <- Remote.byUUID u
+ case mr of
+ Nothing -> noop
+ Just r -> setRemoteIgnore (R.repo r) False
return True
unknownNameError :: String -> Annex a
@@ -85,8 +91,12 @@ unknownNameError prefix = do
else Remote.prettyPrintUUIDsDescs
"known special remotes"
descm (M.keys m)
- nouuids <- filterM (\r -> (==) NoUUID <$> getRepoUUID r)
- =<< Annex.fromRepo Git.remotes
- let nouuidmsg = unlines $ map ("\t" ++) $
- mapMaybe Git.remoteName nouuids
- error $ concat $ filter (not . null) [prefix ++ "\n", nouuidmsg, specialmsg]
+ disabledremotes <- filterM isdisabled =<< Annex.fromRepo Git.remotes
+ let remotesmsg = unlines $ map ("\t" ++) $
+ mapMaybe Git.remoteName disabledremotes
+ error $ concat $ filter (not . null) [prefix ++ "\n", remotesmsg, specialmsg]
+ where
+ isdisabled r = anyM id
+ [ (==) NoUUID <$> getRepoUUID r
+ , remoteAnnexIgnore <$> Annex.getRemoteGitConfig r
+ ]
diff --git a/Config.hs b/Config.hs
index 0ff688dac..75d7b4ce7 100644
--- a/Config.hs
+++ b/Config.hs
@@ -80,6 +80,12 @@ setRemoteCost r c = setConfig (remoteConfig r "cost") (show c)
setRemoteAvailability :: Git.Repo -> Availability -> Annex ()
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 = annexDirect <$> Annex.getGitConfig
diff --git a/Remote/Git.hs b/Remote/Git.hs
index 0528f9f88..403c91b4f 100644
--- a/Remote/Git.hs
+++ b/Remote/Git.hs
@@ -247,7 +247,7 @@ tryGitConfigRead autoinit r
-- Cache when http remote is not bare for
-- optimisation.
unless (Git.Config.isBare r') $
- setremote "annex-bare" (Git.Config.boolConfig False)
+ setremote setRemoteBare False
return r'
store = observe $ \r' -> do
@@ -274,21 +274,18 @@ tryGitConfigRead autoinit r
return r
set_ignore msg longmessage = do
- let k = "annex-ignore"
case Git.remoteName r of
Nothing -> noop
Just n -> do
- warning $ "Remote " ++ n ++ " " ++ msg ++ "; setting " ++ k
+ warning $ "Remote " ++ n ++ " " ++ msg ++ "; setting annex-ignore"
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"
- setremote k (Git.Config.boolConfig True)
+ 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 setRemoteIgnore True
- setremote k v = case Git.remoteName r of
+ setremote setter v = case Git.remoteName r of
Nothing -> noop
- Just n -> do
- let k' = "remote." ++ n ++ "." ++ k
- inRepo $ Git.Command.run [Param "config", Param k', Param v]
-
+ Just n -> setter r v
+
handlegcrypt Nothing = return r
handlegcrypt (Just _cacheduuid) = do
-- Generate UUID from the gcrypt-id
diff --git a/doc/git-annex-enableremote.mdwn b/doc/git-annex-enableremote.mdwn
index d63dfaf62..d424f6056 100644
--- a/doc/git-annex-enableremote.mdwn
+++ b/doc/git-annex-enableremote.mdwn
@@ -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
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
[[git-annex]](1)