{"thread":{"id":"2249","subject":"[PATCH 3/8] Implement a test for git-fetch-pack/git-upload-pack","startedAt":"2005-10-28T02:47:38Z","lastAt":"2005-10-28T02:47:38Z","messageCount":1,"participants":["Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":8},"messages":[{"id":"10736","messageId":"Pine.LNX.4.63.0510280447190.20516@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"2249","inReplyTo":null,"subject":"[PATCH 3/8] Implement a test for git-fetch-pack/git-upload-pack","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2005-10-28T02:47:38Z","receivedAt":"2005-10-28T02:47:38Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nThis test provides a minimal example of what went wrong with the old\ngit-fetch-pack (and now works beautifully).\n\nSigned-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n\n---\n\n t/t5500-fetch-pack.sh |  136 +++++++++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 136 insertions(+), 0 deletions(-)\n create mode 100644 t/t5500-fetch-pack.sh\n\napplies-to: 641053c478870febdf3b6c525821f1bfdc43a2a5\n1dfccc68d5700ea5c0f062aaf77fdf76a9c06a5e\ndiff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh\nnew file mode 100644\nindex 0000000..0781bd2\n--- /dev/null\n+++ b/t/t5500-fetch-pack.sh\n@@ -0,0 +1,136 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2005 Johannes Schindelin\n+#\n+\n+test_description='Testing multi_ack pack fetching\n+\n+'\n+. ./test-lib.sh\n+\n+# Test fetch-pack/upload-pack pair.\n+\n+# Some convenience functions\n+\n+function show_count () {\n+\tcommit_count=$(($commit_count+1))\n+\tprintf \"      %d\\r\" $commit_count\n+}\n+\n+function add () {\n+\tlocal name=$1\n+\tlocal text=\"$@\"\n+\tlocal branch=${name:0:1}\n+\tlocal parents=\"\"\n+\n+\tshift\n+\twhile test $1; do\n+\t\tparents=\"$parents -p $1\"\n+\t\tshift\n+\tdone\n+\n+\techo \"$text\" > test.txt\n+\tgit-update-index --add test.txt\n+\ttree=$(git-write-tree)\n+\t# make sure timestamps are in correct order\n+\tsec=$(($sec+1))\n+\tcommit=$(echo \"$text\" | GIT_AUTHOR_DATE=$sec \\\n+\t\tgit-commit-tree $tree $parents 2>>log2.txt)\n+\texport $name=$commit\n+\techo $commit > .git/refs/heads/$branch\n+\teval ${branch}TIP=$commit\n+}\n+\n+function count_objects () {\n+\tls .git/objects/??/* 2>>log2.txt | wc -l | tr -d \" \"\n+}\n+\n+function test_expect_object_count () {\n+\tlocal message=$1\n+\tlocal count=$2\n+\n+\toutput=\"$(count_objects)\"\n+\ttest_expect_success \\\n+\t\t\"new object count $message\" \\\n+\t\t\"test $count = $output\"\n+}\n+\n+function test_repack () {\n+\tlocal rep=$1\n+\n+\ttest_expect_success \"repack && prune-packed in $rep\" \\\n+\t\t'(git-repack && git-prune-packed)2>>log.txt'\n+}\n+\n+function pull_to_client () {\n+\tlocal number=$1\n+\tlocal heads=$2\n+\tlocal count=$3\n+\tlocal no_strict_count_check=$4\n+\n+\tcd client\n+\ttest_expect_success \"$number pull\" \\\n+\t\t\"git-fetch-pack -v .. $heads > log.txt 2>&1\"\n+\tcase \"$heads\" in *A*) echo $ATIP > .git/refs/heads/A;; esac\n+\tcase \"$heads\" in *B*) echo $BTIP > .git/refs/heads/B;; esac\n+\tgit-symbolic-ref HEAD refs/heads/${heads:0:1}\n+\ttest_expect_success \"fsck\" 'git-fsck-objects --full > fsck.txt 2>&1'\n+\ttest_expect_object_count \"after $number pull\" $count\n+\tpack_count=$(grep Packing log.txt|tr -dc \"0-9\")\n+\ttest -z \"$pack_count\" && pack_count=0\n+\tif [ -z \"$no_strict_count_check\" ]; then\n+\t\ttest_expect_success \"minimal count\" \"test $count = $pack_count\"\n+\telse\n+\t\ttest $count != $pack_count && \\\n+\t\t\techo \"WARNING: $pack_count objects transmitted, only $count of which were needed\"\n+\tfi\n+\tcd ..\n+}\n+\n+# Here begins the actual testing\n+\n+# A1 - ... - A20 - A21\n+#    \\\n+#      B1  -   B2 - .. - B70\n+\n+# client pulls A20, B1. Then tracks only B. Then pulls A.\n+\n+(\n+\tmkdir client &&\n+\tcd client &&\n+\tgit-init-db 2>> log2.txt\n+)\n+\n+add A1\n+\n+prev=1; cur=2; while [ $cur -le 10 ]; do\n+\tadd A$cur $(eval echo \\$A$prev)\n+\tprev=$cur\n+\tcur=$(($cur+1))\n+done\n+\n+add B1 $A1\n+\n+echo $ATIP > .git/refs/heads/A\n+echo $BTIP > .git/refs/heads/B\n+git-symbolic-ref HEAD refs/heads/B\n+\n+pull_to_client 1st \"B A\" $((11*3))\n+\n+(cd client; test_repack client)\n+\n+add A11 $A10\n+\n+prev=1; cur=2; while [ $cur -le 65 ]; do\n+\tadd B$cur $(eval echo \\$B$prev)\n+\tprev=$cur\n+\tcur=$(($cur+1))\n+done\n+\n+pull_to_client 2nd \"B\" $((64*3))\n+\n+(cd client; test_repack client)\n+\n+pull_to_client 3rd \"A\" $((1*3)) # old fails\n+\n+test_done\n---\n0.99.8.GIT\n"}]}