Skip to content

Commit 019b21d

Browse files
peffttaylorr
authored andcommitted
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 <[email protected]> Signed-off-by: Taylor Blau <[email protected]>
1 parent 8b5763e commit 019b21d

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

t/t5550-http-fetch-dumb.sh

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,14 @@ test_expect_success 'fetch notices corrupt idx' '
307307
)
308308
'
309309

310+
# usage: count_fetches <nr> <extension> <trace_file>
311+
count_fetches () {
312+
# ignore grep exit code; it may return non-zero if we are expecting no
313+
# matches
314+
grep "GET .*objects/pack/pack-[a-z0-9]*.$2" "$3" >trace.count
315+
test_line_count = "$1" trace.count
316+
}
317+
310318
test_expect_success 'fetch can handle previously-fetched .idx files' '
311319
git checkout --orphan branch1 &&
312320
echo base >file &&
@@ -321,8 +329,14 @@ test_expect_success 'fetch can handle previously-fetched .idx files' '
321329
git push "$HTTPD_DOCUMENT_ROOT_PATH"/repo_packed_branches.git branch2 &&
322330
git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH"/repo_packed_branches.git repack -d &&
323331
git --bare init clone_packed_branches.git &&
324-
git --git-dir=clone_packed_branches.git fetch "$HTTPD_URL"/dumb/repo_packed_branches.git branch1:branch1 &&
325-
git --git-dir=clone_packed_branches.git fetch "$HTTPD_URL"/dumb/repo_packed_branches.git branch2:branch2
332+
GIT_TRACE_CURL=$PWD/one.trace git --git-dir=clone_packed_branches.git \
333+
fetch "$HTTPD_URL"/dumb/repo_packed_branches.git branch1:branch1 &&
334+
count_fetches 2 idx one.trace &&
335+
count_fetches 1 pack one.trace &&
336+
GIT_TRACE_CURL=$PWD/two.trace git --git-dir=clone_packed_branches.git \
337+
fetch "$HTTPD_URL"/dumb/repo_packed_branches.git branch2:branch2 &&
338+
count_fetches 0 idx two.trace &&
339+
count_fetches 1 pack two.trace
326340
'
327341

328342
test_expect_success 'did not use upload-pack service' '

0 commit comments

Comments
 (0)