builtin/submodule: allow cloning with different ref storage format
As submodules are proper self-contained repositories, it is perfectly valid for them to have a different ref storage format than their parent repository. There is no obvious way for users to ask for the ref storage format when initializing submodules though. Whether the setup of such mixed-ref-storage-format constellations is all that useful remains to be seen. But there is no good reason to not expose such an option, and we will require it in a subsequent patch. Introduce a new `--ref-format=` option for git-submodule(1) that allows the user to pick the ref storage format. This option will also be used in a subsequent commit, where we start to propagate the same flag from git-clone(1) to cloning submodules with the `--recursive` switch. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
d9ab8788e1
commit
5ac781ad62
41
t/t7424-submodule-mixed-ref-formats.sh
Executable file
41
t/t7424-submodule-mixed-ref-formats.sh
Executable file
@ -0,0 +1,41 @@
|
||||
#!/bin/sh
|
||||
|
||||
test_description='submodules handle mixed ref storage formats'
|
||||
|
||||
. ./test-lib.sh
|
||||
|
||||
test_ref_format () {
|
||||
echo "$2" >expect &&
|
||||
git -C "$1" rev-parse --show-ref-format >actual &&
|
||||
test_cmp expect actual
|
||||
}
|
||||
|
||||
for OTHER_FORMAT in files reftable
|
||||
do
|
||||
if test "$OTHER_FORMAT" = "$GIT_DEFAULT_REF_FORMAT"
|
||||
then
|
||||
continue
|
||||
fi
|
||||
|
||||
test_expect_success 'setup' '
|
||||
git config set --global protocol.file.allow always
|
||||
'
|
||||
|
||||
test_expect_success 'clone submodules with different ref storage format' '
|
||||
test_when_finished "rm -rf submodule upstream downstream" &&
|
||||
|
||||
git init submodule &&
|
||||
test_commit -C submodule submodule-initial &&
|
||||
git init upstream &&
|
||||
git -C upstream submodule add "file://$(pwd)/submodule" &&
|
||||
git -C upstream commit -m "upstream submodule" &&
|
||||
|
||||
git clone --no-recurse-submodules "file://$(pwd)/upstream" downstream &&
|
||||
test_ref_format downstream "$GIT_DEFAULT_REF_FORMAT" &&
|
||||
git -C downstream submodule update --init --ref-format=$OTHER_FORMAT &&
|
||||
test_ref_format downstream/submodule "$OTHER_FORMAT"
|
||||
'
|
||||
|
||||
done
|
||||
|
||||
test_done
|
Reference in New Issue
Block a user