On Mon, Aug 27, 2018 at 03:12:56PM -0700, Stefan Beller wrote:
> When cloning a superproject with the option
>  --recurse-submodules='.', it is easy to find yourself wanting
> a submodule active, but not having that submodule present in
> the modules directory.
> 
> Signed-off-by: Stefan Beller <sbel...@google.com>
> ---
>  t/t2013-checkout-submodule.sh | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
> 
> diff --git a/t/t2013-checkout-submodule.sh b/t/t2013-checkout-submodule.sh
> index 6ef15738e44..c69640fc341 100755
> --- a/t/t2013-checkout-submodule.sh
> +++ b/t/t2013-checkout-submodule.sh
> @@ -63,6 +63,30 @@ test_expect_success '"checkout <submodule>" honors 
> submodule.*.ignore from .git/
>       ! test -s actual
>  '
>  
> +test_expect_success 'setup superproject with historic submodule' '
> +     test_create_repo super1 &&
> +     test_create_repo sub1 &&
> +     test_commit -C sub1 sub_content &&
> +     git -C super1 submodule add ../sub1 &&
> +     git -C super1 commit -a -m "sub1 added" &&
> +     test_commit -C super1 historic_state &&
> +     git -C super1 rm sub1 &&
> +     git -C super1 commit -a -m "deleted sub" &&
> +     test_commit -C super1 new_state &&

These six consecutive commands above all specify the '-C super1'
options ...

> +     test_path_is_missing super1/sub &&
> +
> +     # The important part is to ensure sub1 is not in there any more.
> +     # There is another series in flight, that may remove an
> +     # empty .gitmodules file entirely.
> +     test_must_be_empty super1/.gitmodules

... and both of these two checks use the 'super1/' path prefix.  I
think it would be more readable to simply 'cd super1' first.

> +'
> +
> +test_expect_failure 'checkout old state with deleted submodule' '
> +     test_when_finished "rm -rf super1 sub1 super1_clone" &&
> +     git clone --recurse-submodules super1 super1_clone &&
> +     git -C super1_clone checkout --recurse-submodules historic_state
> +'
> +
>  KNOWN_FAILURE_DIRECTORY_SUBMODULE_CONFLICTS=1
>  test_submodule_switch_recursing_with_args "checkout"
>  
> -- 
> 2.18.0
> 

Reply via email to