[PATCHv2 2/4] git submodule: Fix adding of submodules at paths with ./

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

 



Make 'git submodule add' strip './' from the submodule path in the same
way as 'git ls-files' does, so that 'git submodule init' looks up the
information in .gitmodules with the same key under which 'git submodule
add' stores it.

Signed-off-by: Michael J Gruber <git@xxxxxxxxxxxxxxxxxxxx>
---
Note that the init step implicitly tests whether add recorded the correct path.
 
   git-submodule.sh           |    3 +++
 t/t7400-submodule-basic.sh |    2 +-
 2 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/git-submodule.sh b/git-submodule.sh
index 204aab6..4f26be4 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -167,6 +167,9 @@ cmd_add()
 	;;
 	esac
 
+	# strip superfluous ./ from path
+	path=$(echo "$path" | sed -e 's|^\(\./\)*||' -e's|/\./|/|g')
+
 	# strip trailing slashes from path
 	path=$(echo "$path" | sed -e 's|/*$||')
 
diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh
index b154050..1757732 100755
--- a/t/t7400-submodule-basic.sh
+++ b/t/t7400-submodule-basic.sh
@@ -59,7 +59,7 @@ test_expect_success 'submodule add' '
 	git submodule init
 '
 
-test_expect_failure 'submodule add with ./ in path' '
+test_expect_success 'submodule add with ./ in path' '
 	git submodule add "$submodurl" ././dotsubmod/./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