3 # Copyright (c) 2019 Denton Liu
6 test_description
='Test submodules set-branch subcommand
8 This test verifies that the set-branch subcommand of git-submodule is working
12 TEST_PASSES_SANITIZE_LEAK
=true
16 test_expect_success
'setup' '
17 git config --global protocol.file.allow always
20 test_expect_success
'submodule config cache setup' '
27 git checkout -b topic &&
35 git submodule add ../submodule &&
36 git commit -m "add submodule"
40 test_expect_success
'ensure submodule branch is unset' '
42 ! grep branch .gitmodules
46 test_expect_success
'test submodule set-branch --branch' '
48 git submodule set-branch --branch topic submodule &&
49 grep "branch = topic" .gitmodules &&
50 git submodule update --remote &&
51 cat <<-\EOF >expect &&
54 git -C submodule show -s --pretty=%s >actual &&
55 test_cmp expect actual
59 test_expect_success
'test submodule set-branch --default' '
60 test_commit -C submodule c &&
62 git submodule set-branch --default submodule &&
63 ! grep branch .gitmodules &&
64 git submodule update --remote &&
65 cat <<-\EOF >expect &&
68 git -C submodule show -s --pretty=%s >actual &&
69 test_cmp expect actual
73 test_expect_success
'test submodule set-branch -b' '
74 test_commit -C submodule b &&
76 git submodule set-branch -b topic submodule &&
77 grep "branch = topic" .gitmodules &&
78 git submodule update --remote &&
79 cat <<-\EOF >expect &&
82 git -C submodule show -s --pretty=%s >actual &&
83 test_cmp expect actual
87 test_expect_success
'test submodule set-branch -d' '
88 test_commit -C submodule d &&
90 git submodule set-branch -d submodule &&
91 ! grep branch .gitmodules &&
92 git submodule update --remote &&
93 cat <<-\EOF >expect &&
96 git -C submodule show -s --pretty=%s >actual &&
97 test_cmp expect actual