From 74034ec7812e776ebc9e761feb47309eee4d9d7d Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 22 Aug 2013 12:01:53 -0400 Subject: [PATCH] Better error message when trying to use a git remote that has annex.ignore set. --- Config.hs | 3 +++ Remote.hs | 16 ++++++++++------ debian/changelog | 2 ++ doc/bugs/cannot_determine_uuid_for_origin.mdwn | 13 +++++++++++++ 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/Config.hs b/Config.hs index 4d93a2af51..c37481ead9 100644 --- a/Config.hs +++ b/Config.hs @@ -18,6 +18,9 @@ import Config.Cost type UnqualifiedConfigKey = String data ConfigKey = ConfigKey String +instance Show ConfigKey where + show (ConfigKey s) = s + {- Looks up a setting in git config. -} getConfig :: ConfigKey -> String -> Annex String getConfig (ConfigKey key) def = fromRepo $ Git.Config.get key def diff --git a/Remote.hs b/Remote.hs index ea93172825..5dec6f3e54 100644 --- a/Remote.hs +++ b/Remote.hs @@ -55,6 +55,7 @@ import Logs.UUID import Logs.Trust import Logs.Location hiding (logStatus) import Remote.List +import Config {- Map from UUIDs of Remotes to a calculated value. -} remoteMap :: (Remote -> a) -> Annex (M.Map UUID a) @@ -81,13 +82,16 @@ byName (Just n) = either error Just <$> byName' n {- Like byName, but the remote must have a configured UUID. -} byNameWithUUID :: Maybe String -> Annex (Maybe Remote) -byNameWithUUID n = do - v <- byName n - return $ checkuuid <$> v +byNameWithUUID = checkuuid <=< byName where - checkuuid r - | uuid r == NoUUID = error $ "cannot determine uuid for " ++ name r - | otherwise = r + checkuuid Nothing = return Nothing + checkuuid (Just r) + | uuid r == NoUUID = do + let e = "cannot determine uuid for " ++ name r + if remoteAnnexIgnore (gitconfig r) + then error $ e ++ " (" ++ show (remoteConfig (repo r) "ignore") ++ " is set)" + else error e + | otherwise = return $ Just r byName' :: String -> Annex (Either String Remote) byName' "" = return $ Left "no remote specified" diff --git a/debian/changelog b/debian/changelog index 0aaad39585..120dc69dc1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -10,6 +10,8 @@ git-annex (4.20130816) UNRELEASED; urgency=low * Set --clobber when running wget to ensure resuming works properly. * unused: Pay attention to symlinks that are not yet staged in the index. * Unescape characters in 'file://...' URIs. (Thanks, guilhem for the patch.) + * Better error message when trying to use a git remote that has annex.ignore + set. -- Joey Hess Thu, 15 Aug 2013 15:47:52 +0200 diff --git a/doc/bugs/cannot_determine_uuid_for_origin.mdwn b/doc/bugs/cannot_determine_uuid_for_origin.mdwn index 6d032c630c..ce46e5733a 100644 --- a/doc/bugs/cannot_determine_uuid_for_origin.mdwn +++ b/doc/bugs/cannot_determine_uuid_for_origin.mdwn @@ -120,3 +120,16 @@ Update: it seems te problem was that I had the following in my `.git/config`: fetch = +refs/heads/*:refs/remotes/marcos-bare/* I have *no* idea how that `annex-ignore` got there, but that was the root of my problem. Removing it it allowed my to do `git annex copy`. I really don't know how this happened, but I guess this is [[done]], although I believe this error message is really confusing and could be improved. + +> `annex-ignore` is set automatically by git-annex if it fails to query +> the uuid of a remote the first time it tries to use it. It will say +> when it does that. The assumption +> is that a remote whose uuid cannot be looked up is a git remote +> on a server w/o git-annex support (like github) and it would be annoying +> to constantly be trying and failing to get that uuid. +> +> So, I've improved the error message. Now when annex-ignore is set +> for a remote, the error you got will mention that. +> +> (Also, there is not currently anything lacking in git-annex's support +> for bare repositories.) --[[Joey]]