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

Re: [PATCH v2 2/6] tests: Use `git submodule add` instead of `git add`

From
Glen Choo <chooglen@google.com>
Date
Mar 6, 2023, 21:26 UTC
Message-ID
<kl6l5ybdeflj.fsf@chooglen-macbookpro.roam.corp.google.com>
In-Reply-To
<20230228185642.2357806-2-calvinwan@google.com>
Calvin Wan <calvinwan@google.com> writes:
>                                           This commit cleans up such
> test cases where minimal other changes are required (e.g., committing
> later changes to .gitmodules or changing the counts of committed files
> in the worktree).

Okay, though perhaps not detailed enough to explain why these changes were needed in some circumstances. It might be helpful to explain the exact differences that you are adjusting for, i.e.:

- 'git submodule add' requires a './'-prefixed path
- 'git submodule add' changes and tracks .gitmodules
Show 13 quoted lines
> diff --git a/t/t2013-checkout-submodule.sh b/t/t2013-checkout-submodule.sh
> index b2bdd1fcb4..dd2858648b 100755
> --- a/t/t2013-checkout-submodule.sh
> +++ b/t/t2013-checkout-submodule.sh
> @@ -10,7 +10,7 @@ test_expect_success 'setup' '
>  	(cd submodule &&
>  	 git init &&
>  	 test_commit first) &&
> -	git add submodule &&
> +	git submodule add ./submodule &&
>  	test_tick &&
>  	git commit -m superproject &&
>  	(cd submodule &&

Junio mentioned that the change from submodule to ./submodule was surprising, but this seemed quite clear to me. Maybe that's just a sign that I've worked on submodules for too long.

Show 15 quoted lines
> @@ -51,6 +51,7 @@ test_expect_success '"checkout <submodule>" honors submodule.*.ignore from .gitm
>  	git config diff.ignoreSubmodules none &&
>  	git config -f .gitmodules submodule.submodule.path submodule &&
>  	git config -f .gitmodules submodule.submodule.ignore untracked &&
> +	git commit -m "Update patterns in .gitmodules" .gitmodules &&
>  	git checkout HEAD >actual 2>&1 &&
>  	test_must_be_empty actual
>  '
> @@ -59,6 +60,7 @@ test_expect_success '"checkout <submodule>" honors submodule.*.ignore from .git/
>  	git config -f .gitmodules submodule.submodule.ignore none &&
>  	git config submodule.submodule.path submodule &&
>  	git config submodule.submodule.ignore all &&
> +	git commit -m "Update patterns in .gitmodules" .gitmodules &&
>  	git checkout HEAD >actual 2>&1 &&
>  	test_must_be_empty actual

I puzzled a lot over why these changes were necessary. The answer is that .gitmodules was formerly untracked, so it didn't show up in the list of files during checkout. But, now that we use 'git submodule add', we do track .gitmodules, so we instead 'fix' the test by committing the .gitmodules. This one is unobvious enough that I think it's worth calling out specifically in the commit message.

Previous: Calvin WanNext: Calvin Wan
Message 29 of 40 in “add: block invalid submodules”
  1. 0/6 add: block invalid submodulesCalvin Wan, Feb 13, 2023
  2. 1/6 leak fix: cache_put_pathCalvin Wan, Feb 13, 2023
  3. Junio C HamanoFeb 13, 2023
  4. Calvin WanFeb 14, 2023
  5. Junio C HamanoFeb 14, 2023
  6. Calvin WanFeb 14, 2023
  7. Junio C HamanoFeb 14, 2023
  8. 3/6 tests: Use `git submodule add` instead of `git add`Calvin Wan, Feb 13, 2023
  9. 4/6 tests: use `git submodule add` and fix expected diffsCalvin Wan, Feb 13, 2023
  10. Junio C HamanoFeb 13, 2023
  11. Junio C HamanoFeb 13, 2023
  12. 5/6 tests: use `git submodule add` and fix expected statusCalvin Wan, Feb 13, 2023
  13. 6/6 add: reject nested repositoriesCalvin Wan, Feb 13, 2023
  14. Jeff KingFeb 13, 2023
  15. Junio C HamanoFeb 14, 2023
  16. Jeff KingFeb 14, 2023
  17. Junio C HamanoFeb 14, 2023
  18. Calvin WanFeb 14, 2023
  19. 2/6 t4041, t4060: modernize test styleCalvin Wan, Feb 13, 2023
  20. Junio C HamanoFeb 13, 2023
  21. Calvin WanFeb 14, 2023
  22. 0/6 add: block invalid submodulesCalvin Wan, Feb 28, 2023
  23. 1/6 t4041, t4060: modernize test styleCalvin Wan, Feb 28, 2023
  24. Glen ChooMar 6, 2023
  25. Calvin WanMar 6, 2023
  26. 2/6 tests: Use `git submodule add` instead of `git add`Calvin Wan, Feb 28, 2023
  27. Junio C HamanoFeb 28, 2023
  28. Calvin WanMar 3, 2023
  29. Glen ChooMar 6, 2023
  30. 3/6 tests: use `git submodule add` and fix expected diffsCalvin Wan, Feb 28, 2023
  31. Glen ChooMar 6, 2023
  32. Junio C HamanoMar 6, 2023
  33. 4/6 tests: use `git submodule add` and fix expected statusCalvin Wan, Feb 28, 2023
  34. Glen ChooMar 7, 2023
  35. 5/6 tests: remove duplicate .gitmodules pathCalvin Wan, Feb 28, 2023
  36. Junio C HamanoFeb 28, 2023
  37. Calvin WanMar 2, 2023
  38. Glen ChooMar 7, 2023
  39. 6/6 add: reject nested repositoriesCalvin Wan, Feb 28, 2023
  40. Glen ChooMar 7, 2023

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.