summaryrefslogtreecommitdiff
path: root/t/t5537-fetch-shallow.sh
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2018-07-24 14:50:44 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2018-07-24 14:50:44 -0700
commit88df0fa6597fd32b0394c544fb37d6655bd34a13 (patch)
tree994bc28a9b8fc27ca1cf2460a8377c79e737d9f6 /t/t5537-fetch-shallow.sh
parentMerge branch 'jk/for-each-ref-icase' (diff)
parentfetch-pack: write shallow, then check connectivity (diff)
downloadtgif-88df0fa6597fd32b0394c544fb37d6655bd34a13.tar.xz
Merge branch 'jt/connectivity-check-after-unshallow'
"git fetch" failed to correctly validate the set of objects it received when making a shallow history deeper, which has been corrected. * jt/connectivity-check-after-unshallow: fetch-pack: write shallow, then check connectivity fetch-pack: implement ref-in-want fetch-pack: put shallow info in output parameter fetch: refactor to make function args narrower fetch: refactor fetch_refs into two functions fetch: refactor the population of peer ref OIDs upload-pack: test negotiation with changing repository upload-pack: implement ref-in-want test-pkt-line: add unpack-sideband subcommand
Diffstat (limited to 't/t5537-fetch-shallow.sh')
-rwxr-xr-xt/t5537-fetch-shallow.sh43
1 files changed, 43 insertions, 0 deletions
diff --git a/t/t5537-fetch-shallow.sh b/t/t5537-fetch-shallow.sh
index 943231af96..7045685e2d 100755
--- a/t/t5537-fetch-shallow.sh
+++ b/t/t5537-fetch-shallow.sh
@@ -186,4 +186,47 @@ EOF
test_cmp expect actual
'
+. "$TEST_DIRECTORY"/lib-httpd.sh
+start_httpd
+
+REPO="$HTTPD_DOCUMENT_ROOT_PATH/repo"
+
+test_expect_success 'shallow fetches check connectivity before writing shallow file' '
+ rm -rf "$REPO" client &&
+
+ git init "$REPO" &&
+ test_commit -C "$REPO" one &&
+ test_commit -C "$REPO" two &&
+ test_commit -C "$REPO" three &&
+
+ git init client &&
+
+ # Use protocol v2 to ensure that shallow information is sent exactly
+ # once by the server, since we are planning to manipulate it.
+ git -C "$REPO" config protocol.version 2 &&
+ git -C client config protocol.version 2 &&
+
+ git -C client fetch --depth=2 "$HTTPD_URL/one_time_sed/repo" master:a_branch &&
+
+ # Craft a situation in which the server sends back an unshallow request
+ # with an empty packfile. This is done by refetching with a shorter
+ # depth (to ensure that the packfile is empty), and overwriting the
+ # shallow line in the response with the unshallow line we want.
+ printf "s/0034shallow %s/0036unshallow %s/" \
+ "$(git -C "$REPO" rev-parse HEAD)" \
+ "$(git -C "$REPO" rev-parse HEAD^)" \
+ >"$HTTPD_ROOT_PATH/one-time-sed" &&
+ test_must_fail git -C client fetch --depth=1 "$HTTPD_URL/one_time_sed/repo" \
+ master:a_branch &&
+
+ # Ensure that the one-time-sed script was used.
+ ! test -e "$HTTPD_ROOT_PATH/one-time-sed" &&
+
+ # Ensure that the resulting repo is consistent, despite our failure to
+ # fetch.
+ git -C client fsck
+'
+
+stop_httpd
+
test_done