blame: large-scale performance rewrite
[gitweb.git] / t / t5503-tagfollow.sh
index 4074e23ffa2c7a93fdbd4a367e273118224b9038..f30c03885cda050f0bc704428ffa8a66932ff3fd 100755 (executable)
@@ -35,21 +35,31 @@ test_expect_success setup '
 '
 
 U=UPLOAD_LOG
+UPATH="$(pwd)/$U"
 
+test_expect_success 'setup expect' '
 cat - <<EOF >expect
-#S
 want $A
-#E
 EOF
+'
+
+get_needs () {
+       test -s "$1" &&
+       perl -alne '
+               next unless $F[1] eq "upload-pack<";
+               last if $F[2] eq "0000";
+               print $F[2], " ", $F[3];
+       ' "$1"
+}
+
 test_expect_success 'fetch A (new commit : 1 connection)' '
-       rm -f $U
+       rm -f $U &&
        (
                cd cloned &&
-               GIT_DEBUG_SEND_PACK=3 git fetch 3>../$U &&
+               GIT_TRACE_PACKET=$UPATH git fetch &&
                test $A = $(git rev-parse --verify origin/master)
        ) &&
-       test -s $U &&
-       cut -d" " -f1,2 $U >actual &&
+       get_needs $U >actual &&
        test_cmp expect actual
 '
 
@@ -65,23 +75,23 @@ test_expect_success "create tag T on A, create C on branch cat" '
        git checkout master
 '
 
+test_expect_success 'setup expect' '
 cat - <<EOF >expect
-#S
 want $C
 want $T
-#E
 EOF
+'
+
 test_expect_success 'fetch C, T (new branch, tag : 1 connection)' '
-       rm -f $U
+       rm -f $U &&
        (
                cd cloned &&
-               GIT_DEBUG_SEND_PACK=3 git fetch 3>../$U &&
+               GIT_TRACE_PACKET=$UPATH git fetch &&
                test $C = $(git rev-parse --verify origin/cat) &&
                test $T = $(git rev-parse --verify tag1) &&
                test $A = $(git rev-parse --verify tag1^0)
        ) &&
-       test -s $U &&
-       cut -d" " -f1,2 $U >actual &&
+       get_needs $U >actual &&
        test_cmp expect actual
 '
 
@@ -101,32 +111,33 @@ test_expect_success "create commits O, B, tag S on B" '
        S=$(git rev-parse --verify tag2)
 '
 
+test_expect_success 'setup expect' '
 cat - <<EOF >expect
-#S
 want $B
 want $S
-#E
 EOF
+'
+
 test_expect_success 'fetch B, S (commit and tag : 1 connection)' '
-       rm -f $U
+       rm -f $U &&
        (
                cd cloned &&
-               GIT_DEBUG_SEND_PACK=3 git fetch 3>../$U &&
+               GIT_TRACE_PACKET=$UPATH git fetch &&
                test $B = $(git rev-parse --verify origin/master) &&
                test $B = $(git rev-parse --verify tag2^0) &&
                test $S = $(git rev-parse --verify tag2)
        ) &&
-       test -s $U &&
-       cut -d" " -f1,2 $U >actual &&
+       get_needs $U >actual &&
        test_cmp expect actual
 '
 
+test_expect_success 'setup expect' '
 cat - <<EOF >expect
-#S
 want $B
 want $S
-#E
 EOF
+'
+
 test_expect_success 'new clone fetch master and tags' '
        git branch -D cat
        rm -f $U
@@ -135,15 +146,14 @@ test_expect_success 'new clone fetch master and tags' '
                cd clone2 &&
                git init &&
                git remote add origin .. &&
-               GIT_DEBUG_SEND_PACK=3 git fetch 3>../$U &&
+               GIT_TRACE_PACKET=$UPATH git fetch &&
                test $B = $(git rev-parse --verify origin/master) &&
                test $S = $(git rev-parse --verify tag2) &&
                test $B = $(git rev-parse --verify tag2^0) &&
                test $T = $(git rev-parse --verify tag1) &&
                test $A = $(git rev-parse --verify tag1^0)
        ) &&
-       test -s $U &&
-       cut -d" " -f1,2 $U >actual &&
+       get_needs $U >actual &&
        test_cmp expect actual
 '