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/t5614-clone-submodules-shallow.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 / t5614-clone-submodules-shallow.sh` 130 lines ยท 3937 bytes Raw Blame History 1 #!/bin/sh 2 3 test_description='Test shallow cloning of repos with submodules' 4 5 . ./test-lib.sh 6 7 pwd=$(pwd) 8 9 test_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 25 test_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 35 test_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 45 test_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 55 test_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 65 test_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 75 test_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 94 test_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 111 test_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 130 test_done