sync: Fix parsing of gcrypt::rsync:// urls that use a relative path

Such an url is not valid; parseURI will fail on it. But git-annex doesn't
actually need to parse the url, because all it needs to do to support
syncing with it is know that it's not a local path, and use git pull and
push.

(Note that there is no good reason for the user to use such an url. An
absolute url is valid and I patched git-remote-gcrypt to support them
years ago. Still, users gonna do anything that tools allow, and
git-remote-gcrypt still supports them.)

Sponsored-by: Jack Hill on Patreon
This commit is contained in:
Joey Hess 2023-03-23 15:19:04 -04:00
parent 0e18bf029e
commit a0badc5069
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
12 changed files with 45 additions and 22 deletions

View file

@ -266,7 +266,7 @@ gCryptSetup _ mu _ c gc = go $ fromProposedAccepted <$> M.lookup gitRepoField c
let u = genUUIDInNameSpace gCryptNameSpace gcryptid
if Just u == mu || isNothing mu
then do
method <- setupRepo gcryptid =<< inRepo (Git.Construct.fromRemoteLocation gitrepo)
method <- setupRepo gcryptid =<< inRepo (Git.Construct.fromRemoteLocation gitrepo False)
gitConfigSpecialRemote u c' [("gcrypt", fromAccessMethod method)]
return (c', u)
else giveup $ "uuid mismatch; expected " ++ show mu ++ " but remote gitrepo has " ++ show u ++ " (" ++ show gcryptid ++ ")"

View file

@ -102,7 +102,7 @@ list autoinit = do
Nothing -> return r
Just url -> inRepo $ \g ->
Git.Construct.remoteNamed n $
Git.Construct.fromRemoteLocation (Git.fromConfigValue url) g
Git.Construct.fromRemoteLocation (Git.fromConfigValue url) False g
{- Git remotes are normally set up using standard git commands, not
- git-annex initremote and enableremote.
@ -118,7 +118,7 @@ gitSetup :: SetupStage -> Maybe UUID -> Maybe CredPair -> RemoteConfig -> Remote
gitSetup Init mu _ c _ = do
let location = maybe (giveup "Specify location=url") fromProposedAccepted $
M.lookup locationField c
r <- inRepo $ Git.Construct.fromRemoteLocation location
r <- inRepo $ Git.Construct.fromRemoteLocation location False
r' <- tryGitConfigRead False r False
let u = getUncachedUUID r'
if u == NoUUID

View file

@ -203,7 +203,7 @@ configKnownUrl r
<$> M.lookup Annex.SpecialRemote.Config.typeField c
u <- fromProposedAccepted
<$> M.lookup urlField c
let u' = Git.Remote.parseRemoteLocation u g
let u' = Git.Remote.parseRemoteLocation u False g
return $ Git.Remote.RemoteUrl (Git.repoLocation r) == u'
&& t == typename remote
go u mcu = do