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/t5538-push-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 / t5538-push-shallow.sh` 167 lines ยท 3894 bytes Raw Blame History 1 #!/bin/sh 2 3 test_description='push from/to a shallow clone' 4 5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main 6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME 7 8 . ./test-lib.sh 9 10 commit() { 11 echo "$1" >tracked && 12 git add tracked && 13 git commit -m "$1" 14 } 15 16 test_expect_success 'setup' ' 17 git config --global transfer.fsckObjects true && 18 commit 1 && 19 commit 2 && 20 commit 3 && 21 commit 4 && 22 git clone . full && 23 ( 24 git init full-abc && 25 cd full-abc && 26 commit a && 27 commit b && 28 commit c 29 ) && 30 git clone --no-local --depth=2 .git shallow && 31 git --git-dir=shallow/.git log --format=%s >actual && 32 cat <expect && 33 4 34 3 35 EOF 36 test_cmp expect actual && 37 git clone --no-local --depth=2 full-abc/.git shallow2 && 38 git --git-dir=shallow2/.git log --format=%s >actual && 39 cat <expect && 40 c 41 b 42 EOF 43 test_cmp expect actual 44 ' 45 46 test_expect_success 'push from shallow clone' ' 47 ( 48 cd shallow && 49 commit 5 && 50 git push ../.git +main:refs/remotes/shallow/main 51 ) && 52 git log --format=%s shallow/main >actual && 53 git fsck && 54 cat <expect && 55 5 56 4 57 3 58 2 59 1 60 EOF 61 test_cmp expect actual 62 ' 63 64 test_expect_success 'push from shallow clone, with grafted roots' ' 65 ( 66 cd shallow2 && 67 test_must_fail git push ../.git +main:refs/remotes/shallow2/main 2>err && 68 test_grep "shallow2/main.*shallow update not allowed" err 69 ) && 70 test_must_fail git rev-parse shallow2/main && 71 git fsck 72 ' 73 74 test_expect_success 'add new shallow root with receive.updateshallow on' ' 75 test_config receive.shallowupdate true && 76 ( 77 cd shallow2 && 78 git push ../.git +main:refs/remotes/shallow2/main 79 ) && 80 git log --format=%s shallow2/main >actual && 81 git fsck && 82 cat <expect && 83 c 84 b 85 EOF 86 test_cmp expect actual 87 ' 88 89 test_expect_success 'push from shallow to shallow' ' 90 ( 91 cd shallow && 92 git --git-dir=../shallow2/.git config receive.shallowupdate true && 93 git push ../shallow2/.git +main:refs/remotes/shallow/main && 94 git --git-dir=../shallow2/.git config receive.shallowupdate false 95 ) && 96 ( 97 cd shallow2 && 98 git log --format=%s shallow/main >actual && 99 git fsck && 100 cat <expect && 101 5 102 4 103 3 104 EOF 105 test_cmp expect actual 106 ) 107 ' 108 109 test_expect_success 'push from full to shallow' ' 110 ! git --git-dir=shallow2/.git cat-file blob $(echo 1|git hash-object --stdin) && 111 commit 1 && 112 git push shallow2/.git +main:refs/remotes/top/main && 113 ( 114 cd shallow2 && 115 git log --format=%s top/main >actual && 116 git fsck && 117 cat <expect && 118 1 119 4 120 3 121 EOF 122 test_cmp expect actual && 123 git cat-file blob $(echo 1|git hash-object --stdin) >/dev/null 124 ) 125 ' 126 127 test_expect_success 'push new commit from shallow clone has correct object count' ' 128 git init origin && 129 test_commit -C origin a && 130 test_commit -C origin b && 131 132 git clone --depth=1 "file://$(pwd)/origin" client && 133 git -C client checkout -b topic && 134 git -C client commit --allow-empty -m "empty" && 135 GIT_PROGRESS_DELAY=0 git -C client push --progress origin topic 2>err && 136 test_grep "Enumerating objects: 1, done." err 137 ' 138 139 test_expect_success 'push new commit from shallow clone has good deltas' ' 140 git init base && 141 test_seq 1 999 >base/a && 142 test_commit -C base initial && 143 git -C base add a && 144 git -C base commit -m "big a" && 145 146 git clone --depth=1 "file://$(pwd)/base" deltas && 147 git -C deltas checkout -b deltas && 148 test_seq 1 1000 >deltas/a && 149 git -C deltas commit -a -m "bigger a" && 150 GIT_PROGRESS_DELAY=0 git -C deltas push --progress origin deltas 2>err && 151 152 test_grep "Enumerating objects: 5, done" err && 153 154 # If the delta base is found, then this message uses "bytes". 155 # If the delta base is not found, then this message uses "KiB". 156 test_grep "Writing objects: .* bytes" err && 157 158 git -C deltas commit --amend -m "changed message" && 159 GIT_TRACE2_EVENT="$(pwd)/config-push.txt" \ 160 GIT_PROGRESS_DELAY=0 git -C deltas -c pack.usePathWalk=true \ 161 push --progress -f origin deltas 2>err && 162 163 test_grep "Enumerating objects: 1, done" err && 164 test_region pack-objects path-walk config-push.txt 165 ' 166 167 test_done