Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/t/t7419-submodule-set-branch.sh # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / t / t7419-submodule-set-branch.sh` 130 lines ยท 3192 bytes Raw Blame History 1 #!/bin/sh 2 # 3 # Copyright (c) 2019 Denton Liu 4 # 5 6 test_description='Test submodules set-branch subcommand 7 8 This test verifies that the set-branch subcommand of git-submodule is working 9 as expected. 10 ' 11 12 TEST_NO_CREATE_REPO=1 13 14 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main 15 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME 16 17 . ./test-lib.sh 18 19 test_expect_success 'setup' ' 20 git config --global protocol.file.allow always 21 ' 22 23 test_expect_success 'submodule config cache setup' ' 24 mkdir submodule && 25 (cd submodule && 26 git init && 27 echo a >a && 28 git add . && 29 git commit -ma && 30 git checkout -b topic && 31 echo b >a && 32 git add . && 33 git commit -mb && 34 git checkout main 35 ) && 36 mkdir super && 37 (cd super && 38 git init && 39 git submodule add ../submodule && 40 git submodule add --name thename ../submodule thepath && 41 git commit -m "add submodules" 42 ) 43 ' 44 45 test_expect_success 'ensure submodule branch is unset' ' 46 (cd super && 47 test_cmp_config "" -f .gitmodules --default "" submodule.submodule.branch 48 ) 49 ' 50 51 test_expect_success 'test submodule set-branch --branch' ' 52 (cd super && 53 git submodule set-branch --branch topic submodule && 54 test_cmp_config topic -f .gitmodules submodule.submodule.branch && 55 git submodule update --remote && 56 cat <<-\EOF >expect && 57 b 58 EOF 59 git -C submodule show -s --pretty=%s >actual && 60 test_cmp expect actual 61 ) 62 ' 63 64 test_expect_success 'test submodule set-branch --default' ' 65 (cd super && 66 git submodule set-branch --default submodule && 67 test_cmp_config "" -f .gitmodules --default "" submodule.submodule.branch && 68 git submodule update --remote && 69 cat <<-\EOF >expect && 70 a 71 EOF 72 git -C submodule show -s --pretty=%s >actual && 73 test_cmp expect actual 74 ) 75 ' 76 77 test_expect_success 'test submodule set-branch -b' ' 78 (cd super && 79 git submodule set-branch -b topic submodule && 80 test_cmp_config topic -f .gitmodules submodule.submodule.branch && 81 git submodule update --remote && 82 cat <<-\EOF >expect && 83 b 84 EOF 85 git -C submodule show -s --pretty=%s >actual && 86 test_cmp expect actual 87 ) 88 ' 89 90 test_expect_success 'test submodule set-branch -d' ' 91 (cd super && 92 git submodule set-branch -d submodule && 93 test_cmp_config "" -f .gitmodules --default "" submodule.submodule.branch && 94 git submodule update --remote && 95 cat <<-\EOF >expect && 96 a 97 EOF 98 git -C submodule show -s --pretty=%s >actual && 99 test_cmp expect actual 100 ) 101 ' 102 103 test_expect_success 'test submodule set-branch --branch with named submodule' ' 104 (cd super && 105 git submodule set-branch --branch topic thepath && 106 test_cmp_config topic -f .gitmodules submodule.thename.branch && 107 test_cmp_config "" -f .gitmodules --default "" submodule.thepath.branch && 108 git submodule update --remote && 109 cat <<-\EOF >expect && 110 b 111 EOF 112 git -C thepath show -s --pretty=%s >actual && 113 test_cmp expect actual 114 ) 115 ' 116 117 test_expect_success 'test submodule set-branch --default with named submodule' ' 118 (cd super && 119 git submodule set-branch --default thepath && 120 test_cmp_config "" -f .gitmodules --default "" submodule.thename.branch && 121 git submodule update --remote && 122 cat <<-\EOF >expect && 123 a 124 EOF 125 git -C thepath show -s --pretty=%s >actual && 126 test_cmp expect actual 127 ) 128 ' 129 130 test_done