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 'submodule config cache setup' '
22 git checkout -b topic &&
30 git submodule add ../submodule &&
31 git commit -m "add submodule"
35 test_expect_success 'ensure submodule branch is unset' '
37 test_must_fail grep branch .gitmodules
41 test_expect_success 'test submodule set-branch --branch' '
43 git submodule set-branch --branch topic submodule &&
44 grep "branch = topic" .gitmodules &&
45 git submodule update --remote &&
46 cat <<-\EOF >expect &&
49 git -C submodule show -s --pretty=%s >actual &&
50 test_cmp expect actual
54 test_expect_success 'test submodule set-branch --default' '
56 git submodule set-branch --default submodule &&
57 test_must_fail grep branch .gitmodules &&
58 git submodule update --remote &&
59 cat <<-\EOF >expect &&
62 git -C submodule show -s --pretty=%s >actual &&
63 test_cmp expect actual
67 test_expect_success 'test submodule set-branch -b' '
69 git submodule set-branch -b topic submodule &&
70 grep "branch = topic" .gitmodules &&
71 git submodule update --remote &&
72 cat <<-\EOF >expect &&
75 git -C submodule show -s --pretty=%s >actual &&
76 test_cmp expect actual
80 test_expect_success 'test submodule set-branch -d' '
82 git submodule set-branch -d submodule &&
83 test_must_fail grep branch .gitmodules &&
84 git submodule update --remote &&
85 cat <<-\EOF >expect &&
88 git -C submodule show -s --pretty=%s >actual &&
89 test_cmp expect actual