connect.c: mark more strings for translation
[gitweb.git] / t / t5500-fetch-pack.sh
index f20bb59d22e9a9143e1c1bb3125677b33306d583..d2d27f9b54ecafccc530df0e77e1aadeb0fcbccc 100755 (executable)
@@ -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 @@ 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 @@ 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
 '
 
@@ -403,7 +403,7 @@ test_expect_success 'fetch creating new shallow root' '
                git fetch --depth=1 --progress 2>actual &&
                # This should fetch only the empty commit, no tree or
                # blob objects
-               grep "remote: Total 1" actual
+               test_i18ngrep "remote: Total 1" actual
        )
 '
 
@@ -482,25 +482,25 @@ test_expect_success 'set up tests of missing reference' '
 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' '
@@ -528,6 +528,37 @@ test_expect_success 'test --all with tag to non-tip' '
        )
 '
 
+test_expect_success 'test --all wrt tag to non-commits' '
+       # create tag-to-{blob,tree,commit,tag}, making sure all tagged objects
+       # 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) &&
+       git tag -a -m "tag -> tag" tag-to-tag $tag &&
+ \
+       # `fetch-pack --all` should succeed fetching all those objects.
+       mkdir fetchall &&
+       (
+               cd fetchall &&
+               git init &&
+               git fetch-pack --all .. &&
+               git cat-file blob $blob >/dev/null &&
+               git cat-file tree $tree >/dev/null &&
+               git cat-file commit $commit >/dev/null &&
+               git cat-file tag $tag >/dev/null
+       )
+'
+
 test_expect_success 'shallow fetch with tags does not break the repository' '
        mkdir repo1 &&
        (
@@ -557,6 +588,41 @@ test_expect_success 'fetch-pack can fetch a raw sha1' '
        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
@@ -686,6 +752,17 @@ test_expect_success 'fetch shallow since ...' '
        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 &&
        (
@@ -730,4 +807,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