"git fetch" into a lazy clone forgot to fetch base objects that are
necessary to complete delta in a thin packfile, which has been
corrected.
* jt/partial-clone-missing-ref-delta-base:
t5616: cover case of client having delta base
t5616: use correct flag to check object is missing
index-pack: prefetch missing REF_DELTA bases
t5616: refactor packfile replacement
@ -244,11 +244,25 @@ test_expect_success 'fetch what is specified on CLI even if already promised' '
@@ -244,11 +244,25 @@ test_expect_success 'fetch what is specified on CLI even if already promised' '
. "$TEST_DIRECTORY"/lib-httpd.sh
start_httpd
# Converts bytes into a form suitable for inclusion in a sed command. For
# example, "printf 'ab\r\n' | hex_unpack" results in '\x61\x62\x0d\x0a'.
# Inserts $1 at the start of the string and every 2 characters thereafter.
intersperse () {
sed 's/\(..\)/'$1'\1/g'
}
# Create a one-time-sed command to replace the existing packfile with $1.
replace_packfile () {
# The protocol requires that the packfile be sent in sideband 1, hence
# the extra \x01 byte at the beginning.
printf "1,/packfile/!c %04x\\\\x01%s0000" \
"$(($(wc -c <$1) + 5))" \
"$(hex_unpack <$1 | intersperse '\\x')" \
>"$HTTPD_ROOT_PATH/one-time-sed"
}
test_expect_success 'upon cloning, check that all refs point to objects' '
@ -270,10 +284,7 @@ test_expect_success 'upon cloning, check that all refs point to objects' '
@@ -270,10 +284,7 @@ test_expect_success 'upon cloning, check that all refs point to objects' '
# Replace the existing packfile with the crafted one. The protocol
# requires that the packfile be sent in sideband 1, hence the extra
# \x01 byte at the beginning.
printf "1,/packfile/!c %04x\\\\x01%s0000" \
"$(($(wc -c <incomplete.pack) + 5))" \
"$(sed_escape <incomplete.pack)" \
>"$HTTPD_ROOT_PATH/one-time-sed" &&
replace_packfile incomplete.pack &&
# Use protocol v2 because the sed command looks for the "packfile"
# section header.
@ -313,10 +324,7 @@ test_expect_success 'when partial cloning, tolerate server not sending target of
@@ -313,10 +324,7 @@ test_expect_success 'when partial cloning, tolerate server not sending target of
# Replace the existing packfile with the crafted one. The protocol
# requires that the packfile be sent in sideband 1, hence the extra
# \x01 byte at the beginning.
printf "1,/packfile/!c %04x\\\\x01%s0000" \
"$(($(wc -c <incomplete.pack) + 5))" \
"$(sed_escape <incomplete.pack)" \
>"$HTTPD_ROOT_PATH/one-time-sed" &&
replace_packfile incomplete.pack &&
# Use protocol v2 because the sed command looks for the "packfile"
# section header.
@ -331,4 +339,82 @@ test_expect_success 'when partial cloning, tolerate server not sending target of
@@ -331,4 +339,82 @@ test_expect_success 'when partial cloning, tolerate server not sending target of
! test -e "$HTTPD_ROOT_PATH/one-time-sed"
'
test_expect_success 'tolerate server sending REF_DELTA against missing promisor objects' '