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

[PATCHv3 1/2] git submodule: Add test cases for git submodule add

From
Michael J Gruber <git@drmicha.warpmail.net>
Date
Mar 3, 2009, 12:39 UTC
Message-ID
<1236083989-20526-2-git-send-email-git@drmicha.warpmail.net>
In-Reply-To
<1236083989-20526-1-git-send-email-git@drmicha.warpmail.net>

Add simple test cases for adding and initialising submodules. The init step is necessary in order to verify the added information.

The second test exposes a known breakage due to './' in the path: git ls-files simplifies the path but git add does not, which leads to git init looking for different lines in .gitmodules than git add adds.

The other tests add test cases for '//' and '..' in the path which currently fail for the same reason.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
The init step test implicitly whether add and init treat the path in the
same way.
 t/t7400-submodule-basic.sh |   49 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 49 insertions(+), 0 deletions(-)
diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh
index b8cb2df..4f42585 100755
--- a/t/t7400-submodule-basic.sh
+++ b/t/t7400-submodule-basic.sh
@@ -47,6 +47,55 @@ test_expect_success 'Prepare submodule testing' '
 	GIT_CONFIG=.gitmodules git config submodule.example.url git://example.com/init.git
 '
 
+test_expect_success 'Prepare submodule add testing' '
+	submodurl=$(pwd)
+	(
+		mkdir addtest &&
+		cd addtest &&
+		git init
+	)
+'
+
+test_expect_success 'submodule add' '
+	(
+		cd addtest &&
+		git submodule add "$submodurl" submod &&
+		git submodule init
+	)
+'
+
+test_expect_failure 'submodule add with ./ in path' '
+	(
+		cd addtest &&
+		git submodule add "$submodurl" ././dotsubmod/./frotz/./ &&
+		git submodule init
+	)
+'
+
+test_expect_failure 'submodule add with // in path' '
+	(
+		cd addtest &&
+		git submodule add "$submodurl" slashslashsubmod///frotz// &&
+		git submodule init
+	)
+'
+
+test_expect_failure 'submodule add with /.. in path' '
+	(
+		cd addtest &&
+		git submodule add "$submodurl" dotdotsubmod/../realsubmod/frotz/.. &&
+		git submodule init
+	)
+'
+
+test_expect_failure 'submodule add with ./, /.. and // in path' '
+	(
+		cd addtest &&
+		git submodule add "$submodurl" dot/dotslashsubmod/./../..////realsubmod2/frotz//.. &&
+		git submodule init
+	)
+'
+
 test_expect_success 'status should fail for unmapped paths' '
 	if git submodule status
 	then
-- 
1.6.2.rc2
Previous: Michael J GruberNext: Michael J Gruber
Message 20 of 35 in “Fwd: Git Submodule Misbehaviour With ./”
  1. Andrei ThorpFeb 24, 2009
  2. 0/2 Fix git submodule add for paths with ./Michael J Gruber, Feb 25, 2009
  3. 1/2 git submodule: Add test cases for git submodule addMichael J Gruber, Feb 25, 2009
  4. 2/2 git submodule: Fix adding of submodules at paths with ./Michael J Gruber, Feb 25, 2009
  5. Johannes SixtFeb 25, 2009
  6. Michael J GruberFeb 25, 2009
  7. Johannes SixtFeb 25, 2009
  8. 0/4 Fix git submodule add for funky pathsMichael J Gruber, Feb 25, 2009
  9. 1/4 git submodule: Add test cases for git submodule addMichael J Gruber, Feb 25, 2009
  10. 2/4 git submodule: Fix adding of submodules at paths with ./Michael J Gruber, Feb 25, 2009
  11. 3/4 git submodule: Add more tests for add with funky pathsMichael J Gruber, Feb 25, 2009
  12. 4/4 git submodule: Fix handling of // and /.. in paths for added submodulesMichael J Gruber, Feb 25, 2009
  13. Johannes SixtFeb 25, 2009
  14. Michael J GruberFeb 25, 2009
  15. Johannes SixtFeb 25, 2009
  16. Junio C HamanoFeb 25, 2009
  17. Michael J GruberFeb 26, 2009
  18. Junio C HamanoFeb 26, 2009
  19. 0/2 git submodule: normalize paths before addingMichael J Gruber, Mar 3, 2009
  20. 1/2 git submodule: Add test cases for git submodule addMichael J Gruber, Mar 3, 2009
  21. 2/2 git submodule: Fix adding of submodules at paths with ./, .. and //Michael J Gruber, Mar 3, 2009
  22. Johannes SixtMar 3, 2009
  23. Michael J GruberMar 3, 2009
  24. 0/2 git submodule: normalize paths before addingMichael J Gruber, Mar 3, 2009
  25. 1/2 git submodule: Add test cases for git submodule addMichael J Gruber, Mar 3, 2009
  26. 2/2 git submodule: Fix adding of submodules at paths with ./, .. and //Michael J Gruber, Mar 3, 2009
  27. Johannes SixtMar 3, 2009
  28. Michael J GruberMar 3, 2009
  29. Junio C HamanoMar 3, 2009
  30. Junio C HamanoMar 3, 2009
  31. Michael J GruberMar 3, 2009
  32. Johannes SchindelinMar 3, 2009
  33. Michael J GruberMar 3, 2009
  34. Junio C HamanoFeb 25, 2009
  35. Junio C HamanoFeb 25, 2009

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.