aboutsummaryrefslogtreecommitdiffstats
path: root/t/t5550-http-fetch-dumb.sh
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2024-10-25 02:44:17 -0400
committerTaylor Blau <me@ttaylorr.com>2024-10-25 17:35:46 -0400
commit019b21d4022c6e3a43f54a3c16c881e9419e25eb (patch)
treece69538d45a30c0075fceb77cd67c39ac99464cd /t/t5550-http-fetch-dumb.sh
parentmidx: avoid duplicate packed_git entries (diff)
downloadgit-019b21d4022c6e3a43f54a3c16c881e9419e25eb.tar.gz
git-019b21d4022c6e3a43f54a3c16c881e9419e25eb.zip
t5550: count fetches in "previously-fetched .idx" test
We have a test in t5550 that looks at index fetching over dumb http. It creates two branches, each of which is completely stored in its own pack, then fetches the branches independently. What should (and does) happen is that the first fetch grabs both .idx files and one .pack file, and then the fetch of the second branch re-uses the previously downloaded .idx files (fetching none) and grabs the now-required .pack file. Since the next few patches will be touching this area of the code, let's beef up the test a little by checking that we're downloading the expected items at each step. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Taylor Blau <me@ttaylorr.com>
Diffstat (limited to 't/t5550-http-fetch-dumb.sh')
-rwxr-xr-xt/t5550-http-fetch-dumb.sh18
1 files changed, 16 insertions, 2 deletions
diff --git a/t/t5550-http-fetch-dumb.sh b/t/t5550-http-fetch-dumb.sh
index 58189c9f7d..3968b82260 100755
--- a/t/t5550-http-fetch-dumb.sh
+++ b/t/t5550-http-fetch-dumb.sh
@@ -307,6 +307,14 @@ test_expect_success 'fetch notices corrupt idx' '
)
'
+# usage: count_fetches <nr> <extension> <trace_file>
+count_fetches () {
+ # ignore grep exit code; it may return non-zero if we are expecting no
+ # matches
+ grep "GET .*objects/pack/pack-[a-z0-9]*.$2" "$3" >trace.count
+ test_line_count = "$1" trace.count
+}
+
test_expect_success 'fetch can handle previously-fetched .idx files' '
git checkout --orphan branch1 &&
echo base >file &&
@@ -321,8 +329,14 @@ test_expect_success 'fetch can handle previously-fetched .idx files' '
git push "$HTTPD_DOCUMENT_ROOT_PATH"/repo_packed_branches.git branch2 &&
git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH"/repo_packed_branches.git repack -d &&
git --bare init clone_packed_branches.git &&
- git --git-dir=clone_packed_branches.git fetch "$HTTPD_URL"/dumb/repo_packed_branches.git branch1:branch1 &&
- git --git-dir=clone_packed_branches.git fetch "$HTTPD_URL"/dumb/repo_packed_branches.git branch2:branch2
+ GIT_TRACE_CURL=$PWD/one.trace git --git-dir=clone_packed_branches.git \
+ fetch "$HTTPD_URL"/dumb/repo_packed_branches.git branch1:branch1 &&
+ count_fetches 2 idx one.trace &&
+ count_fetches 1 pack one.trace &&
+ GIT_TRACE_CURL=$PWD/two.trace git --git-dir=clone_packed_branches.git \
+ fetch "$HTTPD_URL"/dumb/repo_packed_branches.git branch2:branch2 &&
+ count_fetches 0 idx two.trace &&
+ count_fetches 1 pack two.trace
'
test_expect_success 'did not use upload-pack service' '