git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v6 9/9] submodule: fix normalization to handle repeated ./

From
Jon Seymour <jon.seymour@gmail.com>
Date
May 27, 2012, 13:43 UTC
Message-ID
<1338126210-11517-10-git-send-email-jon.seymour@gmail.com>
In-Reply-To
<1338126210-11517-1-git-send-email-jon.seymour@gmail.com>

Currently path/./foo/./bar is denormalized correctly, but path/foo/././bar is not.

We fix the normalization script to allow repeated application of the ./ -> / normalization in the same way that foo/.. is handled - by moving it inside a sed loop.

The existing sed label, start, is renamed to fooslashdotdotslash to indicate which of the two loops is being refered to by the second branch directive.

Signed-off-by: Jon Seymour <jon.seymour@gmail.com>
---
 git-submodule.sh           | 8 +++++---
 t/t7400-submodule-basic.sh | 6 +++---
 2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/git-submodule.sh b/git-submodule.sh
index 1f0983c..8f3bc71 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -229,10 +229,12 @@ normalize_path()
 		sed -e '
 			s|//*|/|g
 			s|^\(\./\)*||
-			s|/\./|/|g
-			:start
+			:slashdotslash
+			s|/\./|/|
+			tslashdotslash
+			:fooslashdotdotslash
 			s|\([^/]*\)/\.\./||
-			tstart
+			tfooslashdotdotslash
 			s|/*$||
 		'
 }
diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh
index b01f479..61887b2 100755
--- a/t/t7400-submodule-basic.sh
+++ b/t/t7400-submodule-basic.sh
@@ -499,7 +499,7 @@ test_expect_success '../subrepo works with URL - ssh://hostname/repo' '
 	)
 '
 
-test_expect_failure 'relative path works with URL - ssh://hostname/path/././repo' '
+test_expect_success 'relative path works with URL - ssh://hostname/path/././repo' '
 	(
 		cd reltest &&
 		cp pristine-.git-config .git/config &&
@@ -510,7 +510,7 @@ test_expect_failure 'relative path works with URL - ssh://hostname/path/././repo
 	)
 '
 
-test_expect_failure 'relative path works with URL - ssh://hostname/path/detour/././../repo' '
+test_expect_success 'relative path works with URL - ssh://hostname/path/detour/././../repo' '
 	(
 		cd reltest &&
 		cp pristine-.git-config .git/config &&
@@ -685,7 +685,7 @@ test_expect_success 'relative path works with user@host:path/to/./repo' '
 	)
 '
 
-test_expect_failure 'relative path works with user@host:path/to/././repo' '
+test_expect_success 'relative path works with user@host:path/to/././repo' '
 	(
 		cd reltest &&
 		cp pristine-.git-config .git/config &&
-- 
1.7.10.2.656.gb5a46db
Previous: Jon Seymour
Message 12 of 12 in “submodule: improve robustness of path handling”
  1. 0/9 submodule: improve robustness of path handlingJon Seymour, May 27, 2012
  2. 1/9 submodule: additional regression tests for relative URLsJon Seymour, May 27, 2012
  3. 2/9 submodule: document failure to detect invalid submodule URLsJon Seymour, May 27, 2012
  4. 3/9 submodule: document failure to handle relative superproject origin URLsJon Seymour, May 27, 2012
  5. 4/9 submodule: document failure to handle improperly normalized remote origin URLsJon Seymour, May 27, 2012
  6. 5/9 submodule: extract normalize_path into standalone functionJon Seymour, May 27, 2012
  7. 6/9 submodule: fix detection of invalid submodule URLJon Seymour, May 27, 2012
  8. 7/9 submodule: fix sync handling of relative superproject origin URLsJon Seymour, May 27, 2012
  9. Jon SeymourMay 27, 2012
  10. 8/9 submodule: fix handling of denormalized superproject origin URLsJon Seymour, May 27, 2012
  11. Jon SeymourMay 27, 2012
  12. 9/9 submodule: fix normalization to handle repeated ./Jon Seymour, May 27, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.