repair: Improve fetching from a remote with an url in host:path format.

User reported git@my.gitlab.foo:username/myrepo.git didn't work with
git-repair, because it rewrites it to an url
ssh://git@my.gitlab.foo/~/username/myrepo.git
and the /~/ was not something the hosting site supported.

Since git-annex still generally needs the repo url to be well, an url, did
not change the conversion code. But in this case, we're running git fetch,
so we might as well pass it the remote name rather than the url.

Did a quick audit of repoLocation uses to see if there was anything else
like this problem elsewhere, and didn't see any. But this is not the first
time this special case in git and git-annex's attempt to de-special-case
it has caused a problem..
This commit is contained in:
Joey Hess 2020-05-04 15:32:06 -04:00
parent d2e78dfc0d
commit dfc4e641b5
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
2 changed files with 18 additions and 15 deletions

View file

@ -6,6 +6,7 @@ git-annex (8.20200502) UNRELEASED; urgency=medium
* Also display a warning message when a remote, without a known uuid, * Also display a warning message when a remote, without a known uuid,
is located in a directory that does not currently exist, to avoid is located in a directory that does not currently exist, to avoid
silently skipping such a remote. silently skipping such a remote.
* repair: Improve fetching from a remote with an url in host:path format.
-- Joey Hess <id@joeyh.name> Mon, 04 May 2020 12:46:11 -0400 -- Joey Hess <id@joeyh.name> Mon, 04 May 2020 12:46:11 -0400

View file

@ -122,24 +122,26 @@ retrieveMissingObjects missing referencerepo r
) )
pullremotes tmpr (rmt:rmts) fetchrefs ms pullremotes tmpr (rmt:rmts) fetchrefs ms
| not (foundBroken ms) = return ms | not (foundBroken ms) = return ms
| otherwise = do | otherwise = case remoteName rmt of
putStrLn $ "Trying to recover missing objects from remote " ++ repoDescribe rmt ++ "." Just n -> do
ifM (fetchfrom (repoLocation rmt) fetchrefs tmpr) putStrLn $ "Trying to recover missing objects from remote " ++ n ++ "."
( do ifM (fetchfrom n fetchrefs tmpr)
void $ explodePacks tmpr ( do
void $ copyObjects tmpr r void $ explodePacks tmpr
case ms of void $ copyObjects tmpr r
FsckFailed -> pullremotes tmpr rmts fetchrefs ms case ms of
FsckFoundMissing s t -> do FsckFailed -> pullremotes tmpr rmts fetchrefs ms
stillmissing <- findMissing (S.toList s) r FsckFoundMissing s t -> do
pullremotes tmpr rmts fetchrefs (FsckFoundMissing stillmissing t) stillmissing <- findMissing (S.toList s) r
, pullremotes tmpr rmts fetchrefs ms pullremotes tmpr rmts fetchrefs (FsckFoundMissing stillmissing t)
) , pullremotes tmpr rmts fetchrefs ms
fetchfrom fetchurl ps fetchr = runBool ps' fetchr' )
Nothing -> pullremotes tmpr rmts fetchrefs ms
fetchfrom loc ps fetchr = runBool ps' fetchr'
where where
ps' = ps' =
[ Param "fetch" [ Param "fetch"
, Param fetchurl , Param loc
, Param "--force" , Param "--force"
, Param "--update-head-ok" , Param "--update-head-ok"
, Param "--quiet" , Param "--quiet"