Git fork
at reftables-rust 130 lines 3.9 kB view raw
1#!/bin/sh 2 3test_description='Test shallow cloning of repos with submodules' 4 5. ./test-lib.sh 6 7pwd=$(pwd) 8 9test_expect_success 'setup' ' 10 git checkout -b main && 11 test_commit commit1 && 12 test_commit commit2 && 13 mkdir sub && 14 ( 15 cd sub && 16 git init && 17 test_commit subcommit1 && 18 test_commit subcommit2 && 19 test_commit subcommit3 20 ) && 21 git submodule add "file://$pwd/sub" sub && 22 git commit -m "add submodule" 23' 24 25test_expect_success 'nonshallow clone implies nonshallow submodule' ' 26 test_when_finished "rm -rf super_clone" && 27 test_config_global protocol.file.allow always && 28 git clone --recurse-submodules "file://$pwd/." super_clone && 29 git -C super_clone log --oneline >lines && 30 test_line_count = 3 lines && 31 git -C super_clone/sub log --oneline >lines && 32 test_line_count = 3 lines 33' 34 35test_expect_success 'shallow clone with shallow submodule' ' 36 test_when_finished "rm -rf super_clone" && 37 test_config_global protocol.file.allow always && 38 git clone --recurse-submodules --depth 2 --shallow-submodules "file://$pwd/." super_clone && 39 git -C super_clone log --oneline >lines && 40 test_line_count = 2 lines && 41 git -C super_clone/sub log --oneline >lines && 42 test_line_count = 1 lines 43' 44 45test_expect_success 'shallow clone does not imply shallow submodule' ' 46 test_when_finished "rm -rf super_clone" && 47 test_config_global protocol.file.allow always && 48 git clone --recurse-submodules --depth 2 "file://$pwd/." super_clone && 49 git -C super_clone log --oneline >lines && 50 test_line_count = 2 lines && 51 git -C super_clone/sub log --oneline >lines && 52 test_line_count = 3 lines 53' 54 55test_expect_success 'shallow clone with non shallow submodule' ' 56 test_when_finished "rm -rf super_clone" && 57 test_config_global protocol.file.allow always && 58 git clone --recurse-submodules --depth 2 --no-shallow-submodules "file://$pwd/." super_clone && 59 git -C super_clone log --oneline >lines && 60 test_line_count = 2 lines && 61 git -C super_clone/sub log --oneline >lines && 62 test_line_count = 3 lines 63' 64 65test_expect_success 'non shallow clone with shallow submodule' ' 66 test_when_finished "rm -rf super_clone" && 67 test_config_global protocol.file.allow always && 68 git clone --recurse-submodules --no-local --shallow-submodules "file://$pwd/." super_clone && 69 git -C super_clone log --oneline >lines && 70 test_line_count = 3 lines && 71 git -C super_clone/sub log --oneline >lines && 72 test_line_count = 1 lines 73' 74 75test_expect_success 'clone follows shallow recommendation' ' 76 test_when_finished "rm -rf super_clone" && 77 test_config_global protocol.file.allow always && 78 git config -f .gitmodules submodule.sub.shallow true && 79 git add .gitmodules && 80 git commit -m "recommend shallow for sub" && 81 git clone --recurse-submodules --no-local "file://$pwd/." super_clone && 82 ( 83 cd super_clone && 84 git log --oneline >lines && 85 test_line_count = 4 lines 86 ) && 87 ( 88 cd super_clone/sub && 89 git log --oneline >lines && 90 test_line_count = 1 lines 91 ) 92' 93 94test_expect_success 'get unshallow recommended shallow submodule' ' 95 test_when_finished "rm -rf super_clone" && 96 test_config_global protocol.file.allow always && 97 git clone --no-local "file://$pwd/." super_clone && 98 ( 99 cd super_clone && 100 git submodule update --init --no-recommend-shallow && 101 git log --oneline >lines && 102 test_line_count = 4 lines 103 ) && 104 ( 105 cd super_clone/sub && 106 git log --oneline >lines && 107 test_line_count = 3 lines 108 ) 109' 110 111test_expect_success 'clone follows non shallow recommendation' ' 112 test_when_finished "rm -rf super_clone" && 113 test_config_global protocol.file.allow always && 114 git config -f .gitmodules submodule.sub.shallow false && 115 git add .gitmodules && 116 git commit -m "recommend non shallow for sub" && 117 git clone --recurse-submodules --no-local "file://$pwd/." super_clone && 118 ( 119 cd super_clone && 120 git log --oneline >lines && 121 test_line_count = 5 lines 122 ) && 123 ( 124 cd super_clone/sub && 125 git log --oneline >lines && 126 test_line_count = 3 lines 127 ) 128' 129 130test_done