2015-08-18 02:21:57 +02:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Copyright (c) 2014 Heiko Voigt
|
|
|
|
#
|
|
|
|
|
|
|
|
test_description='Test submodules config cache infrastructure
|
|
|
|
|
2015-08-18 02:21:59 +02:00
|
|
|
This test verifies that parsing .gitmodules configurations directly
|
|
|
|
from the database and from the worktree works.
|
2015-08-18 02:21:57 +02:00
|
|
|
'
|
|
|
|
|
|
|
|
TEST_NO_CREATE_REPO=1
|
|
|
|
. ./test-lib.sh
|
|
|
|
|
|
|
|
test_expect_success 'submodule config cache setup' '
|
|
|
|
mkdir submodule &&
|
|
|
|
(cd submodule &&
|
|
|
|
git init &&
|
|
|
|
echo a >a &&
|
|
|
|
git add . &&
|
|
|
|
git commit -ma
|
|
|
|
) &&
|
|
|
|
mkdir super &&
|
|
|
|
(cd super &&
|
|
|
|
git init &&
|
|
|
|
git submodule add ../submodule &&
|
|
|
|
git submodule add ../submodule a &&
|
|
|
|
git commit -m "add as submodule and as a" &&
|
|
|
|
git mv a b &&
|
|
|
|
git commit -m "move a to b"
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
2017-07-25 23:39:14 +02:00
|
|
|
test_expect_success 'configuration parsing with error' '
|
|
|
|
test_when_finished "rm -rf repo" &&
|
|
|
|
test_create_repo repo &&
|
|
|
|
cat >repo/.gitmodules <<-\EOF &&
|
|
|
|
[submodule "s"]
|
|
|
|
path
|
|
|
|
ignore
|
|
|
|
EOF
|
|
|
|
(
|
|
|
|
cd repo &&
|
2018-03-24 08:45:01 +01:00
|
|
|
test_must_fail test-tool submodule-config "" s 2>actual &&
|
2017-07-25 23:39:14 +02:00
|
|
|
test_i18ngrep "bad config" actual
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
2015-08-18 02:21:57 +02:00
|
|
|
cat >super/expect <<EOF
|
|
|
|
Submodule name: 'a' for path 'a'
|
|
|
|
Submodule name: 'a' for path 'b'
|
|
|
|
Submodule name: 'submodule' for path 'submodule'
|
|
|
|
Submodule name: 'submodule' for path 'submodule'
|
|
|
|
EOF
|
|
|
|
|
|
|
|
test_expect_success 'test parsing and lookup of submodule config by path' '
|
|
|
|
(cd super &&
|
2018-03-24 08:45:01 +01:00
|
|
|
test-tool submodule-config \
|
2015-08-18 02:21:57 +02:00
|
|
|
HEAD^ a \
|
|
|
|
HEAD b \
|
|
|
|
HEAD^ submodule \
|
|
|
|
HEAD submodule \
|
|
|
|
>actual &&
|
|
|
|
test_cmp expect actual
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'test parsing and lookup of submodule config by name' '
|
|
|
|
(cd super &&
|
2018-03-24 08:45:01 +01:00
|
|
|
test-tool submodule-config --name \
|
2015-08-18 02:21:57 +02:00
|
|
|
HEAD^ a \
|
|
|
|
HEAD a \
|
|
|
|
HEAD^ submodule \
|
|
|
|
HEAD submodule \
|
|
|
|
>actual &&
|
|
|
|
test_cmp expect actual
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
|
|
|
cat >super/expect_error <<EOF
|
|
|
|
Submodule name: 'a' for path 'b'
|
|
|
|
Submodule name: 'submodule' for path 'submodule'
|
|
|
|
EOF
|
|
|
|
|
|
|
|
test_expect_success 'error in one submodule config lets continue' '
|
|
|
|
(cd super &&
|
|
|
|
cp .gitmodules .gitmodules.bak &&
|
|
|
|
echo " value = \"" >>.gitmodules &&
|
|
|
|
git add .gitmodules &&
|
|
|
|
mv .gitmodules.bak .gitmodules &&
|
|
|
|
git commit -m "add error" &&
|
2018-03-24 08:45:01 +01:00
|
|
|
test-tool submodule-config \
|
2015-08-18 02:21:57 +02:00
|
|
|
HEAD b \
|
|
|
|
HEAD submodule \
|
|
|
|
>actual &&
|
|
|
|
test_cmp expect_error actual
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
2016-07-28 14:49:11 +02:00
|
|
|
test_expect_success 'error message contains blob reference' '
|
|
|
|
(cd super &&
|
|
|
|
sha1=$(git rev-parse HEAD) &&
|
2018-03-24 08:45:01 +01:00
|
|
|
test-tool submodule-config \
|
2016-07-28 14:49:11 +02:00
|
|
|
HEAD b \
|
|
|
|
HEAD submodule \
|
|
|
|
2>actual_err &&
|
2016-08-12 13:59:02 +02:00
|
|
|
test_i18ngrep "submodule-blob $sha1:.gitmodules" actual_err >/dev/null
|
2016-07-28 14:49:11 +02:00
|
|
|
)
|
|
|
|
'
|
|
|
|
|
2016-11-22 21:14:37 +01:00
|
|
|
test_expect_success 'using different treeishs works' '
|
|
|
|
(
|
|
|
|
cd super &&
|
|
|
|
git tag new_tag &&
|
|
|
|
tree=$(git rev-parse HEAD^{tree}) &&
|
|
|
|
commit=$(git rev-parse HEAD^{commit}) &&
|
2018-03-24 08:45:01 +01:00
|
|
|
test-tool submodule-config $commit b >expect &&
|
|
|
|
test-tool submodule-config $tree b >actual.1 &&
|
|
|
|
test-tool submodule-config new_tag b >actual.2 &&
|
2016-11-22 21:14:37 +01:00
|
|
|
test_cmp expect actual.1 &&
|
|
|
|
test_cmp expect actual.2
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
2015-08-18 02:22:00 +02:00
|
|
|
test_expect_success 'error in history in fetchrecursesubmodule lets continue' '
|
|
|
|
(cd super &&
|
|
|
|
git config -f .gitmodules \
|
|
|
|
submodule.submodule.fetchrecursesubmodules blabla &&
|
|
|
|
git add .gitmodules &&
|
|
|
|
git config --unset -f .gitmodules \
|
|
|
|
submodule.submodule.fetchrecursesubmodules &&
|
|
|
|
git commit -m "add error in fetchrecursesubmodules" &&
|
2018-03-24 08:45:01 +01:00
|
|
|
test-tool submodule-config \
|
2015-08-18 02:22:00 +02:00
|
|
|
HEAD b \
|
|
|
|
HEAD submodule \
|
|
|
|
>actual &&
|
|
|
|
test_cmp expect_error actual &&
|
|
|
|
git reset --hard HEAD^
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
2015-08-18 02:21:57 +02:00
|
|
|
test_done
|