summaryrefslogtreecommitdiff
path: root/Remote.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-11-09 13:37:30 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-11-09 13:37:30 -0400
commit4807612214df574e1dd11dff68c7c55dbff73108 (patch)
treeff6577cd034d681373a39fbaf636d6209974a57f /Remote.hs
parente21c56e073d4fe720eb67b7c95daf4333f0f6813 (diff)
Fix bug that caused bad information to be written to the git-annex branch when running describe or other commands with a remote that has no uuid.
Still need to fix crash caused by the bad info.
Diffstat (limited to 'Remote.hs')
-rw-r--r--Remote.hs20
1 files changed, 13 insertions, 7 deletions
diff --git a/Remote.hs b/Remote.hs
index 56a40c71e..e355b0975 100644
--- a/Remote.hs
+++ b/Remote.hs
@@ -90,11 +90,12 @@ byNameWithUUID = checkuuid <=< byName
where
checkuuid Nothing = return Nothing
checkuuid (Just r)
- | uuid r == NoUUID = do
- let e = "cannot determine uuid for " ++ name r
+ | uuid r == NoUUID =
if remoteAnnexIgnore (gitconfig r)
- then error $ e ++ " (" ++ show (remoteConfig (repo r) "ignore") ++ " is set)"
- else error e
+ then error $ noRemoteUUIDMsg r ++
+ " (" ++ show (remoteConfig (repo r) "ignore") ++
+ " is set)"
+ else error $ noRemoteUUIDMsg r
| otherwise = return $ Just r
byName' :: RemoteName -> Annex (Either String Remote)
@@ -111,16 +112,21 @@ byNameOnly n = headMaybe . filter matching <$> remoteList
where
matching r = n == name r
+noRemoteUUIDMsg :: Remote -> String
+noRemoteUUIDMsg r = "cannot determine uuid for " ++ name r
+
{- Looks up a remote by name (or by UUID, or even by description),
- - and returns its UUID. Finds even remotes that are not configured in
- - .git/config. -}
+ - and returns its UUID. Finds even repositories that are not
+ - configured in .git/config. -}
nameToUUID :: RemoteName -> Annex UUID
nameToUUID "." = getUUID -- special case for current repo
nameToUUID "here" = getUUID
nameToUUID "" = error "no remote specified"
nameToUUID n = byName' n >>= go
where
- go (Right r) = return $ uuid r
+ go (Right r) = case uuid r of
+ NoUUID -> error $ noRemoteUUIDMsg r
+ u -> return u
go (Left e) = fromMaybe (error e) <$> bydescription
bydescription = do
m <- uuidMap