Merge branch 'jk/fetch-all-peeled-fix'
authorJunio C Hamano <gitster@pobox.com>
Tue, 24 Jul 2018 21:50:45 +0000 (14:50 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 24 Jul 2018 21:50:46 +0000 (14:50 -0700)
Test modernization.

* jk/fetch-all-peeled-fix:
t5500: prettify non-commit tag tests

1  2 
t/t5500-fetch-pack.sh
diff --combined t/t5500-fetch-pack.sh
index ea6570e81990d73dc07d03c3bb6e6af5c8f029f4,1b756687345207f42985048cbea8351755675ba8..3d33ab3875383f4f71b486bfd3f2fce342e00474
@@@ -30,7 -30,7 +30,7 @@@ add () 
        test_tick &&
        commit=$(echo "$text" | git commit-tree $tree $parents) &&
        eval "$name=$commit; export $name" &&
 -      echo $commit > .git/refs/heads/$branch &&
 +      git update-ref "refs/heads/$branch" "$commit" &&
        eval ${branch}TIP=$commit
  }
  
@@@ -45,10 -45,10 +45,10 @@@ pull_to_client () 
  
                        case "$heads" in
                            *A*)
 -                                  echo $ATIP > .git/refs/heads/A;;
 +                                  git update-ref refs/heads/A "$ATIP";;
                        esac &&
                        case "$heads" in *B*)
 -                          echo $BTIP > .git/refs/heads/B;;
 +                          git update-ref refs/heads/B "$BTIP";;
                        esac &&
                        git symbolic-ref HEAD refs/heads/$(echo $heads \
                                | sed -e "s/^\(.\).*$/\1/") &&
@@@ -92,8 -92,8 +92,8 @@@ test_expect_success 'setup' 
                cur=$(($cur+1))
        done &&
        add B1 $A1 &&
 -      echo $ATIP > .git/refs/heads/A &&
 -      echo $BTIP > .git/refs/heads/B &&
 +      git update-ref refs/heads/A "$ATIP" &&
 +      git update-ref refs/heads/B "$BTIP" &&
        git symbolic-ref HEAD refs/heads/B
  '
  
@@@ -482,25 -482,25 +482,25 @@@ test_expect_success 'set up tests of mi
  test_expect_success 'test lonely missing ref' '
        (
                cd client &&
 -              test_must_fail git fetch-pack --no-progress .. refs/heads/xyzzy
 -      ) >/dev/null 2>error-m &&
 -      test_cmp expect-error error-m
 +              test_must_fail git fetch-pack --no-progress .. refs/heads/xyzzy 2>../error-m
 +      ) &&
 +      test_i18ncmp expect-error error-m
  '
  
  test_expect_success 'test missing ref after existing' '
        (
                cd client &&
 -              test_must_fail git fetch-pack --no-progress .. refs/heads/A refs/heads/xyzzy
 -      ) >/dev/null 2>error-em &&
 -      test_cmp expect-error error-em
 +              test_must_fail git fetch-pack --no-progress .. refs/heads/A refs/heads/xyzzy 2>../error-em
 +      ) &&
 +      test_i18ncmp expect-error error-em
  '
  
  test_expect_success 'test missing ref before existing' '
        (
                cd client &&
 -              test_must_fail git fetch-pack --no-progress .. refs/heads/xyzzy refs/heads/A
 -      ) >/dev/null 2>error-me &&
 -      test_cmp expect-error error-me
 +              test_must_fail git fetch-pack --no-progress .. refs/heads/xyzzy refs/heads/A 2>../error-me
 +      ) &&
 +      test_i18ncmp expect-error error-me
  '
  
  test_expect_success 'test --all, --depth, and explicit head' '
@@@ -533,19 -533,26 +533,26 @@@ test_expect_success 'test --all wrt ta
        # are reachable only via created tag references.
        blob=$(echo "hello blob" | git hash-object -t blob -w --stdin) &&
        git tag -a -m "tag -> blob" tag-to-blob $blob &&
-  \
        tree=$(printf "100644 blob $blob\tfile" | git mktree) &&
        git tag -a -m "tag -> tree" tag-to-tree $tree &&
-  \
        tree2=$(printf "100644 blob $blob\tfile2" | git mktree) &&
        commit=$(git commit-tree -m "hello commit" $tree) &&
        git tag -a -m "tag -> commit" tag-to-commit $commit &&
-  \
        blob2=$(echo "hello blob2" | git hash-object -t blob -w --stdin) &&
-       tag=$(printf "object $blob2\ntype blob\ntag tag-to-blob2\n\
- tagger author A U Thor <author@example.com> 0 +0000\n\nhello tag" | git mktag) &&
+       tag=$(git mktag <<-EOF
+               object $blob2
+               type blob
+               tag tag-to-blob2
+               tagger author A U Thor <author@example.com> 0 +0000
+               hello tag
+       EOF
+       ) &&
        git tag -a -m "tag -> tag" tag-to-tag $tag &&
-  \
        # `fetch-pack --all` should succeed fetching all those objects.
        mkdir fetchall &&
        (
@@@ -588,41 -595,6 +595,41 @@@ test_expect_success 'fetch-pack can fet
        git fetch-pack hidden $(git -C hidden rev-parse refs/hidden/one)
  '
  
 +test_expect_success 'fetch-pack can fetch a raw sha1 that is advertised as a ref' '
 +      rm -rf server client &&
 +      git init server &&
 +      test_commit -C server 1 &&
 +
 +      git init client &&
 +      git -C client fetch-pack ../server \
 +              $(git -C server rev-parse refs/heads/master)
 +'
 +
 +test_expect_success 'fetch-pack can fetch a raw sha1 overlapping a named ref' '
 +      rm -rf server client &&
 +      git init server &&
 +      test_commit -C server 1 &&
 +      test_commit -C server 2 &&
 +
 +      git init client &&
 +      git -C client fetch-pack ../server \
 +              $(git -C server rev-parse refs/tags/1) refs/tags/1
 +'
 +
 +test_expect_success 'fetch-pack cannot fetch a raw sha1 that is not advertised as a ref' '
 +      rm -rf server &&
 +
 +      git init server &&
 +      test_commit -C server 5 &&
 +      git -C server tag -d 5 &&
 +      test_commit -C server 6 &&
 +
 +      git init client &&
 +      test_must_fail git -C client fetch-pack ../server \
 +              $(git -C server rev-parse refs/heads/master^) 2>err &&
 +      test_i18ngrep "Server does not allow request for unadvertised object" err
 +'
 +
  check_prot_path () {
        cat >expected <<-EOF &&
        Diag: url=$1
@@@ -752,17 -724,6 +759,17 @@@ test_expect_success 'fetch shallow sinc
        test_cmp expected actual
  '
  
 +test_expect_success 'clone shallow since selects no commits' '
 +      test_create_repo shallow-since-the-future &&
 +      (
 +      cd shallow-since-the-future &&
 +      GIT_COMMITTER_DATE="100000000 +0700" git commit --allow-empty -m one &&
 +      GIT_COMMITTER_DATE="200000000 +0700" git commit --allow-empty -m two &&
 +      GIT_COMMITTER_DATE="300000000 +0700" git commit --allow-empty -m three &&
 +      test_must_fail git clone --shallow-since "900000000 +0700" "file://$(pwd)/." ../shallow111
 +      )
 +'
 +
  test_expect_success 'shallow clone exclude tag two' '
        test_create_repo shallow-exclude &&
        (
@@@ -807,67 -768,4 +814,67 @@@ test_expect_success 'fetching deepen' 
        )
  '
  
 +test_expect_success 'filtering by size' '
 +      rm -rf server client &&
 +      test_create_repo server &&
 +      test_commit -C server one &&
 +      test_config -C server uploadpack.allowfilter 1 &&
 +
 +      test_create_repo client &&
 +      git -C client fetch-pack --filter=blob:limit=0 ../server HEAD &&
 +
 +      # Ensure that object is not inadvertently fetched
 +      test_must_fail git -C client cat-file -e $(git hash-object server/one.t)
 +'
 +
 +test_expect_success 'filtering by size has no effect if support for it is not advertised' '
 +      rm -rf server client &&
 +      test_create_repo server &&
 +      test_commit -C server one &&
 +
 +      test_create_repo client &&
 +      git -C client fetch-pack --filter=blob:limit=0 ../server HEAD 2> err &&
 +
 +      # Ensure that object is fetched
 +      git -C client cat-file -e $(git hash-object server/one.t) &&
 +
 +      test_i18ngrep "filtering not recognized by server" err
 +'
 +
 +fetch_filter_blob_limit_zero () {
 +      SERVER="$1"
 +      URL="$2"
 +
 +      rm -rf "$SERVER" client &&
 +      test_create_repo "$SERVER" &&
 +      test_commit -C "$SERVER" one &&
 +      test_config -C "$SERVER" uploadpack.allowfilter 1 &&
 +
 +      git clone "$URL" client &&
 +      test_config -C client extensions.partialclone origin &&
 +
 +      test_commit -C "$SERVER" two &&
 +
 +      git -C client fetch --filter=blob:limit=0 origin HEAD:somewhere &&
 +
 +      # Ensure that commit is fetched, but blob is not
 +      test_config -C client extensions.partialclone "arbitrary string" &&
 +      git -C client cat-file -e $(git -C "$SERVER" rev-parse two) &&
 +      test_must_fail git -C client cat-file -e $(git hash-object "$SERVER/two.t")
 +}
 +
 +test_expect_success 'fetch with --filter=blob:limit=0' '
 +      fetch_filter_blob_limit_zero server server
 +'
 +
 +. "$TEST_DIRECTORY"/lib-httpd.sh
 +start_httpd
 +
 +test_expect_success 'fetch with --filter=blob:limit=0 and HTTP' '
 +      fetch_filter_blob_limit_zero "$HTTPD_DOCUMENT_ROOT_PATH/server" "$HTTPD_URL/smart/server"
 +'
 +
 +stop_httpd
 +
 +
  test_done