submodule: add --dissociate option to add/update commands

Add --dissociate option to add and update commands, both clone helper commands
that already have the --reference option --dissociate pairs with.

Signed-off-by: Casey Fitzpatrick <kcghost@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Casey Fitzpatrick
2018-05-03 06:53:46 -04:00
committed by Junio C Hamano
parent 6d33e1c282
commit a0ef29341a
4 changed files with 48 additions and 5 deletions

View File

@ -59,6 +59,16 @@ test_expect_success 'submodule add --reference uses alternates' '
test_alternate_is_used super/.git/modules/sub/objects/info/alternates super/sub
'
test_expect_success 'submodule add --reference with --dissociate does not use alternates' '
(
cd super &&
git submodule add --reference ../B --dissociate "file://$base_dir/A" sub-dissociate &&
git commit -m B-super-added &&
git repack -ad
) &&
test_path_is_missing super/.git/modules/sub-dissociate/objects/info/alternates
'
test_expect_success 'that reference gets used with add' '
(
cd super/sub &&
@ -82,6 +92,13 @@ test_expect_success 'updating superproject keeps alternates' '
test_alternate_is_used super-clone/.git/modules/sub/objects/info/alternates super-clone/sub
'
test_expect_success 'updating superproject with --dissociate does not keep alternates' '
test_when_finished "rm -rf super-clone" &&
git clone super super-clone &&
git -C super-clone submodule update --init --reference ../B --dissociate &&
test_path_is_missing super-clone/.git/modules/sub/objects/info/alternates
'
test_expect_success 'submodules use alternates when cloning a superproject' '
test_when_finished "rm -rf super-clone" &&
git clone --reference super --recursive super super-clone &&