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/t5539-fetch-http-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 / t5539-fetch-http-shallow.sh` 157 lines ยท 4257 bytes Raw Blame History 1 #!/bin/sh 2 3 test_description='fetch/clone from a shallow clone over http' 4 5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main 6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME 7 8 . ./test-lib.sh 9 . "$TEST_DIRECTORY"/lib-httpd.sh 10 start_httpd 11 12 commit() { 13 echo "$1" >tracked && 14 git add tracked && 15 test_tick && 16 git commit -m "$1" 17 } 18 19 test_expect_success 'setup shallow clone' ' 20 test_tick=`1500000000` && 21 commit 1 && 22 commit 2 && 23 commit 3 && 24 commit 4 && 25 commit 5 && 26 commit 6 && 27 commit 7 && 28 git clone --no-local --depth=5 .git shallow && 29 git config --global transfer.fsckObjects true 30 ' 31 32 test_expect_success 'clone http repository' ' 33 git clone --bare --no-local shallow "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" && 34 git clone $HTTPD_URL/smart/repo.git clone && 35 ( 36 cd clone && 37 git fsck && 38 git log --format=%s origin/main >actual && 39 cat <expect && 40 7 41 6 42 5 43 4 44 3 45 EOF 46 test_cmp expect actual 47 ) 48 ' 49 50 # This test is tricky. We need large enough "have"s that fetch-pack 51 # will put pkt-flush in between. Then we need a "have" the server 52 # does not have, it'll send "ACK %s ready" 53 test_expect_success 'no shallow lines after receiving ACK ready' ' 54 ( 55 cd shallow && 56 for i in $(test_seq 15) 57 do 58 git checkout --orphan unrelated$i && 59 test_commit unrelated$i && 60 git push -q "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" \ 61 refs/heads/unrelated$i:refs/heads/unrelated$i && 62 git push -q ../clone/.git \ 63 refs/heads/unrelated$i:refs/heads/unrelated$i || 64 exit 1 65 done && 66 git checkout main && 67 test_commit new && 68 git push "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" main 69 ) && 70 ( 71 cd clone && 72 git checkout --orphan newnew && 73 test_tick=`1400000000` && 74 test_commit new-too && 75 # NEEDSWORK: If the overspecification of the expected result is reduced, we 76 # might be able to run this test in all protocol versions. 77 GIT_TRACE_PACKET="$TRASH_DIRECTORY/trace" GIT_TEST_PROTOCOL_VERSION=0 \ 78 git fetch --depth=2 && 79 test_grep "fetch-pack< ACK .* ready" ../trace && 80 test_grep ! "fetch-pack> done" ../trace 81 ) 82 ' 83 84 test_expect_success 'clone shallow since ...' ' 85 test_create_repo shallow-since && 86 ( 87 cd shallow-since && 88 GIT_COMMITTER_DATE="`100000000` +0700" git commit --allow-empty -m one && 89 GIT_COMMITTER_DATE="`200000000` +0700" git commit --allow-empty -m two && 90 GIT_COMMITTER_DATE="`300000000` +0700" git commit --allow-empty -m three && 91 mv .git "$HTTPD_DOCUMENT_ROOT_PATH/shallow-since.git" && 92 git clone --shallow-since "`300000000` +0700" $HTTPD_URL/smart/shallow-since.git ../shallow11 && 93 git -C ../shallow11 log --pretty=tformat:%s HEAD >actual && 94 echo three >expected && 95 test_cmp expected actual 96 ) 97 ' 98 99 test_expect_success 'fetch shallow since ...' ' 100 git -C shallow11 fetch --shallow-since "`200000000` +0700" origin && 101 git -C shallow11 log --pretty=tformat:%s origin/main >actual && 102 cat >expected <<-\EOF && 103 three 104 two 105 EOF 106 test_cmp expected actual 107 ' 108 109 test_expect_success 'shallow clone exclude tag two' ' 110 test_create_repo shallow-exclude && 111 ( 112 cd shallow-exclude && 113 test_commit one && 114 test_commit two && 115 test_commit three && 116 mv .git "$HTTPD_DOCUMENT_ROOT_PATH/shallow-exclude.git" && 117 git clone --shallow-exclude two $HTTPD_URL/smart/shallow-exclude.git ../shallow12 && 118 git -C ../shallow12 log --pretty=tformat:%s HEAD >actual && 119 echo three >expected && 120 test_cmp expected actual 121 ) 122 ' 123 124 test_expect_success 'fetch exclude tag one' ' 125 git -C shallow12 fetch --shallow-exclude one origin && 126 git -C shallow12 log --pretty=tformat:%s origin/main >actual && 127 test_write_lines three two >expected && 128 test_cmp expected actual 129 ' 130 131 test_expect_success 'fetching deepen' ' 132 test_create_repo shallow-deepen && 133 ( 134 cd shallow-deepen && 135 test_commit one && 136 test_commit two && 137 test_commit three && 138 mv .git "$HTTPD_DOCUMENT_ROOT_PATH/shallow-deepen.git" && 139 git clone --depth 1 $HTTPD_URL/smart/shallow-deepen.git deepen && 140 mv "$HTTPD_DOCUMENT_ROOT_PATH/shallow-deepen.git" .git && 141 test_commit four && 142 git -C deepen log --pretty=tformat:%s main >actual && 143 echo three >expected && 144 test_cmp expected actual && 145 mv .git "$HTTPD_DOCUMENT_ROOT_PATH/shallow-deepen.git" && 146 git -C deepen fetch --deepen=1 && 147 git -C deepen log --pretty=tformat:%s origin/main >actual && 148 cat >expected <<-\EOF && 149 four 150 three 151 two 152 EOF 153 test_cmp expected actual 154 ) 155 ' 156 157 test_done