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
15 test_expect_success
'setup' '
16 git config --global protocol.file.allow always
19 test_expect_success
'submodule config cache setup' '
26 git checkout -b topic &&
34 git submodule add ../submodule &&
35 git commit -m "add submodule"
39 test_expect_success
'ensure submodule branch is unset' '
41 ! grep branch .gitmodules
45 test_expect_success
'test submodule set-branch --branch' '
47 git submodule set-branch --branch topic submodule &&
48 grep "branch = topic" .gitmodules &&
49 git submodule update --remote &&
50 cat <<-\EOF >expect &&
53 git -C submodule show -s --pretty=%s >actual &&
54 test_cmp expect actual
58 test_expect_success
'test submodule set-branch --default' '
59 test_commit -C submodule c &&
61 git submodule set-branch --default submodule &&
62 ! grep branch .gitmodules &&
63 git submodule update --remote &&
64 cat <<-\EOF >expect &&
67 git -C submodule show -s --pretty=%s >actual &&
68 test_cmp expect actual
72 test_expect_success
'test submodule set-branch -b' '
73 test_commit -C submodule b &&
75 git submodule set-branch -b topic submodule &&
76 grep "branch = topic" .gitmodules &&
77 git submodule update --remote &&
78 cat <<-\EOF >expect &&
81 git -C submodule show -s --pretty=%s >actual &&
82 test_cmp expect actual
86 test_expect_success
'test submodule set-branch -d' '
87 test_commit -C submodule d &&
89 git submodule set-branch -d submodule &&
90 ! grep branch .gitmodules &&
91 git submodule update --remote &&
92 cat <<-\EOF >expect &&
95 git -C submodule show -s --pretty=%s >actual &&
96 test_cmp expect actual