t / t5539-fetch-http-shallow.shon commit check_filename: tighten dwim-wildcard ambiguity (df714f8)
   1#!/bin/sh
   2
   3test_description='fetch/clone from a shallow clone over http'
   4
   5. ./test-lib.sh
   6
   7if test -n "$NO_CURL"; then
   8        skip_all='skipping test, git built without http support'
   9        test_done
  10fi
  11
  12. "$TEST_DIRECTORY"/lib-httpd.sh
  13start_httpd
  14
  15commit() {
  16        echo "$1" >tracked &&
  17        git add tracked &&
  18        git commit -m "$1"
  19}
  20
  21test_expect_success 'setup shallow clone' '
  22        commit 1 &&
  23        commit 2 &&
  24        commit 3 &&
  25        commit 4 &&
  26        commit 5 &&
  27        commit 6 &&
  28        commit 7 &&
  29        git clone --no-local --depth=5 .git shallow &&
  30        git config --global transfer.fsckObjects true
  31'
  32
  33test_expect_success 'clone http repository' '
  34        git clone --bare --no-local shallow "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
  35        git clone $HTTPD_URL/smart/repo.git clone &&
  36        (
  37        cd clone &&
  38        git fsck &&
  39        git log --format=%s origin/master >actual &&
  40        cat <<EOF >expect &&
  417
  426
  435
  444
  453
  46EOF
  47        test_cmp expect actual
  48        )
  49'
  50
  51# This test is tricky. We need large enough "have"s that fetch-pack
  52# will put pkt-flush in between. Then we need a "have" the server
  53# does not have, it'll send "ACK %s ready"
  54test_expect_success 'no shallow lines after receiving ACK ready' '
  55        (
  56                cd shallow &&
  57                test_tick &&
  58                for i in $(test_seq 15)
  59                do
  60                        git checkout --orphan unrelated$i &&
  61                        test_commit unrelated$i &&
  62                        git push -q "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" \
  63                                refs/heads/unrelated$i:refs/heads/unrelated$i &&
  64                        git push -q ../clone/.git \
  65                                refs/heads/unrelated$i:refs/heads/unrelated$i ||
  66                        exit 1
  67                done &&
  68                git checkout master &&
  69                test_commit new &&
  70                git push  "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" master
  71        ) &&
  72        (
  73                cd clone &&
  74                git checkout --orphan newnew &&
  75                test_commit new-too &&
  76                GIT_TRACE_PACKET="$TRASH_DIRECTORY/trace" git fetch --depth=2 &&
  77                grep "fetch-pack< ACK .* ready" ../trace &&
  78                ! grep "fetch-pack> done" ../trace
  79        )
  80'
  81
  82stop_httpd
  83test_done