builtin/gc.c: ignore cruft packs with `--keep-largest-pack`
[alt-git.git] / t / t7419-submodule-set-branch.sh
blob232065504cbfdcba60d3f5f69ffb4536b5ae99e8
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
14 . ./test-lib.sh
16 test_expect_success 'setup' '
17 git config --global protocol.file.allow always
20 test_expect_success 'submodule config cache setup' '
21 mkdir submodule &&
22 (cd submodule &&
23 git init &&
24 echo a >a &&
25 git add . &&
26 git commit -ma &&
27 git checkout -b topic &&
28 echo b >a &&
29 git add . &&
30 git commit -mb
31 ) &&
32 mkdir super &&
33 (cd super &&
34 git init &&
35 git submodule add ../submodule &&
36 git commit -m "add submodule"
40 test_expect_success 'ensure submodule branch is unset' '
41 (cd super &&
42 ! grep branch .gitmodules
46 test_expect_success 'test submodule set-branch --branch' '
47 (cd super &&
48 git submodule set-branch --branch topic submodule &&
49 grep "branch = topic" .gitmodules &&
50 git submodule update --remote &&
51 cat <<-\EOF >expect &&
53 EOF
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 &&
61 (cd super &&
62 git submodule set-branch --default submodule &&
63 ! grep branch .gitmodules &&
64 git submodule update --remote &&
65 cat <<-\EOF >expect &&
67 EOF
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 &&
75 (cd super &&
76 git submodule set-branch -b topic submodule &&
77 grep "branch = topic" .gitmodules &&
78 git submodule update --remote &&
79 cat <<-\EOF >expect &&
81 EOF
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 &&
89 (cd super &&
90 git submodule set-branch -d submodule &&
91 ! grep branch .gitmodules &&
92 git submodule update --remote &&
93 cat <<-\EOF >expect &&
95 EOF
96 git -C submodule show -s --pretty=%s >actual &&
97 test_cmp expect actual
101 test_done