#!/bin/sh # # Copyright (c) 2014 Heiko Voigt # test_description='Test submodules config cache infrastructure This test verifies that parsing .gitmodules configurations directly from the database and from the worktree works. ' 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" ) ' cat >super/expect <actual && test_cmp expect actual ) ' test_expect_success 'test parsing and lookup of submodule config by name' ' (cd super && test-submodule-config --name \ HEAD^ a \ HEAD a \ HEAD^ submodule \ HEAD submodule \ >actual && test_cmp expect actual ) ' cat >super/expect_error <>.gitmodules && git add .gitmodules && mv .gitmodules.bak .gitmodules && git commit -m "add error" && test-submodule-config \ HEAD b \ HEAD submodule \ >actual && test_cmp expect_error actual ) ' test_expect_success 'error message contains blob reference' ' (cd super && sha1=$(git rev-parse HEAD) && test-submodule-config \ HEAD b \ HEAD submodule \ 2>actual_err && test_i18ngrep "submodule-blob $sha1:.gitmodules" actual_err >/dev/null ) ' cat >super/expect_url <super/expect_local_path <actual && test_cmp expect_url actual && git config submodule.a.path c && test-submodule-config \ "" c \ "" submodule \ >actual && test_cmp expect_local_path actual && git config submodule.a.url $old_a && git config submodule.submodule.url $old_submodule && git config --unset submodule.a.path c ) ' cat >super/expect_fetchrecurse_die.err <actual.out 2>actual.err && touch expect_fetchrecurse_die.out && test_cmp expect_fetchrecurse_die.out actual.out && test_cmp expect_fetchrecurse_die.err actual.err && git config --unset submodule.submodule.fetchrecursesubmodules ) ' 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" && test-submodule-config \ HEAD b \ HEAD submodule \ >actual && test_cmp expect_error actual && git reset --hard HEAD^ ) ' test_done