t / t4067-diff-partial-clone.shon commit Merge branch 'ds/close-object-store' (5cb7c73)
   1#!/bin/sh
   2
   3test_description='behavior of diff when reading objects in a partial clone'
   4
   5. ./test-lib.sh
   6
   7test_expect_success 'git show batches blobs' '
   8        test_when_finished "rm -rf server client trace" &&
   9
  10        test_create_repo server &&
  11        echo a >server/a &&
  12        echo b >server/b &&
  13        git -C server add a b &&
  14        git -C server commit -m x &&
  15
  16        test_config -C server uploadpack.allowfilter 1 &&
  17        test_config -C server uploadpack.allowanysha1inwant 1 &&
  18        git clone --bare --filter=blob:limit=0 "file://$(pwd)/server" client &&
  19
  20        # Ensure that there is exactly 1 negotiation by checking that there is
  21        # only 1 "done" line sent. ("done" marks the end of negotiation.)
  22        GIT_TRACE_PACKET="$(pwd)/trace" git -C client show HEAD &&
  23        grep "git> done" trace >done_lines &&
  24        test_line_count = 1 done_lines
  25'
  26
  27test_expect_success 'diff batches blobs' '
  28        test_when_finished "rm -rf server client trace" &&
  29
  30        test_create_repo server &&
  31        echo a >server/a &&
  32        echo b >server/b &&
  33        git -C server add a b &&
  34        git -C server commit -m x &&
  35        echo c >server/c &&
  36        echo d >server/d &&
  37        git -C server add c d &&
  38        git -C server commit -m x &&
  39
  40        test_config -C server uploadpack.allowfilter 1 &&
  41        test_config -C server uploadpack.allowanysha1inwant 1 &&
  42        git clone --bare --filter=blob:limit=0 "file://$(pwd)/server" client &&
  43
  44        # Ensure that there is exactly 1 negotiation by checking that there is
  45        # only 1 "done" line sent. ("done" marks the end of negotiation.)
  46        GIT_TRACE_PACKET="$(pwd)/trace" git -C client diff HEAD^ HEAD &&
  47        grep "git> done" trace >done_lines &&
  48        test_line_count = 1 done_lines
  49'
  50
  51test_expect_success 'diff skips same-OID blobs' '
  52        test_when_finished "rm -rf server client trace" &&
  53
  54        test_create_repo server &&
  55        echo a >server/a &&
  56        echo b >server/b &&
  57        git -C server add a b &&
  58        git -C server commit -m x &&
  59        echo another-a >server/a &&
  60        git -C server add a &&
  61        git -C server commit -m x &&
  62
  63        test_config -C server uploadpack.allowfilter 1 &&
  64        test_config -C server uploadpack.allowanysha1inwant 1 &&
  65        git clone --bare --filter=blob:limit=0 "file://$(pwd)/server" client &&
  66
  67        echo a | git hash-object --stdin >hash-old-a &&
  68        echo another-a | git hash-object --stdin >hash-new-a &&
  69        echo b | git hash-object --stdin >hash-b &&
  70
  71        # Ensure that only a and another-a are fetched.
  72        GIT_TRACE_PACKET="$(pwd)/trace" git -C client diff HEAD^ HEAD &&
  73        grep "want $(cat hash-old-a)" trace &&
  74        grep "want $(cat hash-new-a)" trace &&
  75        ! grep "want $(cat hash-b)" trace
  76'
  77
  78test_expect_success 'diff with rename detection batches blobs' '
  79        test_when_finished "rm -rf server client trace" &&
  80
  81        test_create_repo server &&
  82        echo a >server/a &&
  83        printf "b\nb\nb\nb\nb\n" >server/b &&
  84        git -C server add a b &&
  85        git -C server commit -m x &&
  86        rm server/b &&
  87        printf "b\nb\nb\nb\nbX\n" >server/c &&
  88        git -C server add c &&
  89        git -C server commit -a -m x &&
  90
  91        test_config -C server uploadpack.allowfilter 1 &&
  92        test_config -C server uploadpack.allowanysha1inwant 1 &&
  93        git clone --bare --filter=blob:limit=0 "file://$(pwd)/server" client &&
  94
  95        # Ensure that there is exactly 1 negotiation by checking that there is
  96        # only 1 "done" line sent. ("done" marks the end of negotiation.)
  97        GIT_TRACE_PACKET="$(pwd)/trace" git -C client diff -M HEAD^ HEAD >out &&
  98        grep "similarity index" out &&
  99        grep "git> done" trace >done_lines &&
 100        test_line_count = 1 done_lines
 101'
 102
 103test_done