map: Fix buggy handling of remotes that are bare git repositories accessed via ssh

It was treating remote paths of a remote repo as if they were local paths,
and so trying to expand git directories and so forth on them. That led to
bad results, including a path like "foo.git" getting turned into
"foo.git.git"

Sponsored-by: Dartmouth College's OpenNeuro project
This commit is contained in:
Joey Hess 2025-04-22 15:08:49 -04:00
parent 820b591c1f
commit 2ee6c25c72
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
4 changed files with 49 additions and 20 deletions

View file

@ -1,6 +1,6 @@
{- git-annex command
-
- Copyright 2010 Joey Hess <id@joeyh.name>
- Copyright 2010-2025 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU AGPL version 3 or higher.
-}
@ -154,7 +154,7 @@ trustDecorate trustmap u s = case M.lookup u trustmap of
Just DeadTrusted -> Dot.fillColor "grey" s
Nothing -> Dot.fillColor "white" s
{- Recursively searches out remotes starting with the specified repo. -}
{- Recursively searches out remotes starting with the specified local repo. -}
spider :: Git.Repo -> Annex [RepoRemotes]
spider r = spider' [r] []
spider' :: [Git.Repo] -> [RepoRemotes] -> Annex [RepoRemotes]
@ -166,15 +166,18 @@ spider' (r:rs) known
-- The remotes will be relative to r', and need to be
-- made absolute for later use.
remotes <- mapM (absRepo r')
=<< (liftIO $ Git.Construct.fromRemotes r')
remotes <- mapM (absRepo r') =<<
if Git.repoIsUrl r
then liftIO $ Git.Construct.fromRemoteUrlRemotes r'
else liftIO $ Git.Construct.fromRemotes r'
spider' (rs ++ remotes) ((r', remotes):known)
{- Converts repos to a common absolute form. -}
absRepo :: Git.Repo -> Git.Repo -> Annex Git.Repo
absRepo reference r
| Git.repoIsUrl reference = return $ Git.Construct.localToUrl reference r
| Git.repoIsUrl reference = return $
Git.Construct.localToUrl reference r
| Git.repoIsUrl r = return r
| otherwise = liftIO $ do
r' <- Git.Construct.fromPath =<< absPath (Git.repoPath r)