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

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

 



Calvin Wan <calvinwan@xxxxxxxxxx> 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

> 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.

> @@ -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.



[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