From fd493804c004f7facb4b99d4bf21ed49a081c5cf Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 22 Apr 2025 15:45:11 -0400 Subject: [PATCH] map: Avoid looping forever with mutually recursive paths between repositories accessed via ssh Slightly unsatisfying to fix this in Git.Construct.localToUrl rather than in Command.Map.absRepo, which is what map relies on to make repos always use the same path form. But it was already constructing the url with the path there, so that was the easiest place to add normalization. Sponsored-by: Dartmouth College's OpenNeuro project --- CHANGELOG | 2 ++ Git/Construct.hs | 2 +- ...ent_1_cb67146caf6abb5382c6a4c389b76487._comment | 14 -------------- ...ent_3_b86ad77f74b33a28963bde0850df7aa8._comment | 10 ++++++++++ 4 files changed, 13 insertions(+), 15 deletions(-) create mode 100644 doc/bugs/map_goes_into_a_loop_for_a_bare_remote_/comment_3_b86ad77f74b33a28963bde0850df7aa8._comment diff --git a/CHANGELOG b/CHANGELOG index 71168b39d3..f0eeb7b610 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,8 @@ git-annex (10.20250417) UNRELEASED; urgency=medium * map: Fix buggy handling of remotes that are bare git repositories accessed via ssh. + * map: Avoid looping forever with mutually recursive paths between + repositories accessed via ssh. -- Joey Hess Tue, 22 Apr 2025 14:33:26 -0400 diff --git a/Git/Construct.hs b/Git/Construct.hs index 3d37e137c6..7d21c92478 100644 --- a/Git/Construct.hs +++ b/Git/Construct.hs @@ -130,7 +130,7 @@ localToUrl reference r [ s , "//" , auth - , fromOsPath $ + , fromOsPath $ simplifyPath $ toOsPath referencepath repoPath r ] in r { location = Url $ fromJust $ parseURIPortable absurl } diff --git a/doc/bugs/map_goes_into_a_loop_for_a_bare_remote_/comment_1_cb67146caf6abb5382c6a4c389b76487._comment b/doc/bugs/map_goes_into_a_loop_for_a_bare_remote_/comment_1_cb67146caf6abb5382c6a4c389b76487._comment index 2e125ab3c4..a437a22915 100644 --- a/doc/bugs/map_goes_into_a_loop_for_a_bare_remote_/comment_1_cb67146caf6abb5382c6a4c389b76487._comment +++ b/doc/bugs/map_goes_into_a_loop_for_a_bare_remote_/comment_1_cb67146caf6abb5382c6a4c389b76487._comment @@ -15,20 +15,6 @@ Produced what I think is the same bug, or related, though without the looping: Where foo is a remote accessed via ssh, which happens to be on the same host and parent directory as the repo I ran map in, and itself has a remote named foo that has an url of "../foo.git" -Changing the remote to be named foox with url "../foox", and -with the bare remote now at "../foox.git", I started to see some looping too, -though it didn't loop forever: - - map . ok - map origin (sshing...) - ok - map foox (sshing...) - ok - map origin (sshing...) - ok - map foox (sshing...) - ok - One or both problems are caused by `map` using Git.Construct.fromRemotes on the git config that is has gotten by sshing to the remote and listing its config. Git.Construct really is written to operate on local repos, and fromRemotes diff --git a/doc/bugs/map_goes_into_a_loop_for_a_bare_remote_/comment_3_b86ad77f74b33a28963bde0850df7aa8._comment b/doc/bugs/map_goes_into_a_loop_for_a_bare_remote_/comment_3_b86ad77f74b33a28963bde0850df7aa8._comment new file mode 100644 index 0000000000..6c0e7bfecf --- /dev/null +++ b/doc/bugs/map_goes_into_a_loop_for_a_bare_remote_/comment_3_b86ad77f74b33a28963bde0850df7aa8._comment @@ -0,0 +1,10 @@ +[[!comment format=mdwn + username="joey" + subject="""comment 3""" + date="2025-04-22T19:42:40Z" + content=""" +Ok, I added path normalization and that fixed the infinite loop that I saw. + +I'm not 100% sure that it fixed the loop you saw though. Please test a +daily build. +"""]]