[PATCHv2 4/4] git submodule: Fix handling of // and /.. in paths for added submodules

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This hopefully brings "git submodule add"'s parsing of paths in line
with "git submodule init"'s (which uses "git ls-files"), at least for
practical purposes.

It fixes 2 known breakages which are marked "success" now.

Signed-off-by: Michael J Gruber <git@xxxxxxxxxxxxxxxxxxxx>
---
 git-submodule.sh           |    6 ++++++
 t/t7400-submodule-basic.sh |    4 ++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/git-submodule.sh b/git-submodule.sh
index 4f26be4..375362e 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -167,6 +167,12 @@ cmd_add()
 	;;
 	esac
 
+	# simplify multiple /
+	path=$(echo "$path" | sed -e 's|/\+|/|g')
+
+	# resolve /.. (add trailing / for matching /..$)
+	path=$(echo "$path/" | sed -e 's|\([^/]*\)/../||g')
+
 	# strip superfluous ./ from path
 	path=$(echo "$path" | sed -e 's|^\(\./\)*||' -e's|/\./|/|g')
 
diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh
index 21bdfeb..473d0e8 100755
--- a/t/t7400-submodule-basic.sh
+++ b/t/t7400-submodule-basic.sh
@@ -64,12 +64,12 @@ test_expect_success 'submodule add with ./ in path' '
 	git submodule init
 '
 
-test_expect_failure 'submodule add with // in path' '
+test_expect_success 'submodule add with // in path' '
 	git submodule add "$submodurl" slashslashsubmod///frotz// &&
 	git submodule init
 '
 
-test_expect_failure 'submodule add with /.. in path' '
+test_expect_success 'submodule add with /.. in path' '
 	git submodule add "$submodurl" dotdotsubmod/../realsubmod/frotz/.. &&
 	git submodule init
 '
-- 
1.6.2.rc1.30.gd43c

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux