t/README: add missing value for GIT_TEST_DEFAULT_REF_FORMAT
[git/gitster.git] / t / t7419-submodule-set-branch.sh
bloba5d1bc5c54ae095f79bf9b3ee420ba004bb18a88
1 #!/bin/sh
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
9 as expected.
12 TEST_PASSES_SANITIZE_LEAK=true
13 TEST_NO_CREATE_REPO=1
15 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
16 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
18 . ./test-lib.sh
20 test_expect_success 'setup' '
21 git config --global protocol.file.allow always
24 test_expect_success 'submodule config cache setup' '
25 mkdir submodule &&
26 (cd submodule &&
27 git init &&
28 echo a >a &&
29 git add . &&
30 git commit -ma &&
31 git checkout -b topic &&
32 echo b >a &&
33 git add . &&
34 git commit -mb &&
35 git checkout main
36 ) &&
37 mkdir super &&
38 (cd super &&
39 git init &&
40 git submodule add ../submodule &&
41 git submodule add --name thename ../submodule thepath &&
42 git commit -m "add submodules"
46 test_expect_success 'ensure submodule branch is unset' '
47 (cd super &&
48 test_cmp_config "" -f .gitmodules --default "" submodule.submodule.branch
52 test_expect_success 'test submodule set-branch --branch' '
53 (cd super &&
54 git submodule set-branch --branch topic submodule &&
55 test_cmp_config topic -f .gitmodules submodule.submodule.branch &&
56 git submodule update --remote &&
57 cat <<-\EOF >expect &&
59 EOF
60 git -C submodule show -s --pretty=%s >actual &&
61 test_cmp expect actual
65 test_expect_success 'test submodule set-branch --default' '
66 (cd super &&
67 git submodule set-branch --default submodule &&
68 test_cmp_config "" -f .gitmodules --default "" submodule.submodule.branch &&
69 git submodule update --remote &&
70 cat <<-\EOF >expect &&
72 EOF
73 git -C submodule show -s --pretty=%s >actual &&
74 test_cmp expect actual
78 test_expect_success 'test submodule set-branch -b' '
79 (cd super &&
80 git submodule set-branch -b topic submodule &&
81 test_cmp_config topic -f .gitmodules submodule.submodule.branch &&
82 git submodule update --remote &&
83 cat <<-\EOF >expect &&
85 EOF
86 git -C submodule show -s --pretty=%s >actual &&
87 test_cmp expect actual
91 test_expect_success 'test submodule set-branch -d' '
92 (cd super &&
93 git submodule set-branch -d submodule &&
94 test_cmp_config "" -f .gitmodules --default "" submodule.submodule.branch &&
95 git submodule update --remote &&
96 cat <<-\EOF >expect &&
98 EOF
99 git -C submodule show -s --pretty=%s >actual &&
100 test_cmp expect actual
104 test_expect_success 'test submodule set-branch --branch with named submodule' '
105 (cd super &&
106 git submodule set-branch --branch topic thepath &&
107 test_cmp_config topic -f .gitmodules submodule.thename.branch &&
108 test_cmp_config "" -f .gitmodules --default "" submodule.thepath.branch &&
109 git submodule update --remote &&
110 cat <<-\EOF >expect &&
113 git -C thepath show -s --pretty=%s >actual &&
114 test_cmp expect actual
118 test_expect_success 'test submodule set-branch --default with named submodule' '
119 (cd super &&
120 git submodule set-branch --default thepath &&
121 test_cmp_config "" -f .gitmodules --default "" submodule.thename.branch &&
122 git submodule update --remote &&
123 cat <<-\EOF >expect &&
126 git -C thepath show -s --pretty=%s >actual &&
127 test_cmp expect actual
131 test_done