rebase: use correct base for --keep-base when a branch is given
[alt-git.git] / t / t7419-submodule-set-branch.sh
blob3b925c302fc4e2194a2e0ad10c0b48823f2cf021
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_NO_CREATE_REPO=1
13 . ./test-lib.sh
15 test_expect_success 'submodule config cache setup' '
16 mkdir submodule &&
17 (cd submodule &&
18 git init &&
19 echo a >a &&
20 git add . &&
21 git commit -ma &&
22 git checkout -b topic &&
23 echo b >a &&
24 git add . &&
25 git commit -mb
26 ) &&
27 mkdir super &&
28 (cd super &&
29 git init &&
30 git submodule add ../submodule &&
31 git commit -m "add submodule"
35 test_expect_success 'ensure submodule branch is unset' '
36 (cd super &&
37 ! grep branch .gitmodules
41 test_expect_success 'test submodule set-branch --branch' '
42 (cd super &&
43 git submodule set-branch --branch topic submodule &&
44 grep "branch = topic" .gitmodules &&
45 git submodule update --remote &&
46 cat <<-\EOF >expect &&
48 EOF
49 git -C submodule show -s --pretty=%s >actual &&
50 test_cmp expect actual
54 test_expect_success 'test submodule set-branch --default' '
55 test_commit -C submodule c &&
56 (cd super &&
57 git submodule set-branch --default submodule &&
58 ! grep branch .gitmodules &&
59 git submodule update --remote &&
60 cat <<-\EOF >expect &&
62 EOF
63 git -C submodule show -s --pretty=%s >actual &&
64 test_cmp expect actual
68 test_expect_success 'test submodule set-branch -b' '
69 test_commit -C submodule b &&
70 (cd super &&
71 git submodule set-branch -b topic submodule &&
72 grep "branch = topic" .gitmodules &&
73 git submodule update --remote &&
74 cat <<-\EOF >expect &&
76 EOF
77 git -C submodule show -s --pretty=%s >actual &&
78 test_cmp expect actual
82 test_expect_success 'test submodule set-branch -d' '
83 test_commit -C submodule d &&
84 (cd super &&
85 git submodule set-branch -d submodule &&
86 ! grep branch .gitmodules &&
87 git submodule update --remote &&
88 cat <<-\EOF >expect &&
90 EOF
91 git -C submodule show -s --pretty=%s >actual &&
92 test_cmp expect actual
96 test_done