Git fork
at reftables-rust 130 lines 3.2 kB view raw
1#!/bin/sh 2# 3# Copyright (c) 2019 Denton Liu 4# 5 6test_description='Test submodules set-branch subcommand 7 8This test verifies that the set-branch subcommand of git-submodule is working 9as expected. 10' 11 12TEST_NO_CREATE_REPO=1 13 14GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main 15export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME 16 17. ./test-lib.sh 18 19test_expect_success 'setup' ' 20 git config --global protocol.file.allow always 21' 22 23test_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 45test_expect_success 'ensure submodule branch is unset' ' 46 (cd super && 47 test_cmp_config "" -f .gitmodules --default "" submodule.submodule.branch 48 ) 49' 50 51test_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 64test_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 77test_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 90test_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 103test_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 117test_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 130test_done