Skip to content

Commit 6c46f86

Browse files
committed
Merge branch 'jt/transfer-fsck-across-packs-fix'
The code to fsck objects received across multiple packs during a single git fetch session has been broken when the packfile URI feature was in use. A workaround has been added by disabling the codepath to avoid keeping a packfile that is too small. * jt/transfer-fsck-across-packs-fix: fetch-pack: do not mix --pack_header and packfile uri
2 parents be7935e + 2aec3bc commit 6c46f86

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

fetch-pack.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,7 @@ static int get_pack(struct fetch_pack_args *args,
846846
else
847847
demux.out = xd[0];
848848

849-
if (!args->keep_pack && unpack_limit) {
849+
if (!args->keep_pack && unpack_limit && !index_pack_args) {
850850

851851
if (read_pack_header(demux.out, &header))
852852
die(_("protocol error: bad pack header"));
@@ -879,7 +879,7 @@ static int get_pack(struct fetch_pack_args *args,
879879
strvec_push(&cmd.args, "-v");
880880
if (args->use_thin_pack)
881881
strvec_push(&cmd.args, "--fix-thin");
882-
if (do_keep && (args->lock_pack || unpack_limit)) {
882+
if ((do_keep || index_pack_args) && (args->lock_pack || unpack_limit)) {
883883
char hostname[HOST_NAME_MAX + 1];
884884
if (xgethostname(hostname, sizeof(hostname)))
885885
xsnprintf(hostname, sizeof(hostname), "localhost");

t/t5702-protocol-v2.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -881,6 +881,27 @@ test_expect_success 'part of packfile response provided as URI' '
881881
test_line_count = 6 filelist
882882
'
883883

884+
test_expect_success 'packfile URIs with fetch instead of clone' '
885+
P="$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&
886+
rm -rf "$P" http_child log &&
887+
888+
git init "$P" &&
889+
git -C "$P" config "uploadpack.allowsidebandall" "true" &&
890+
891+
echo my-blob >"$P/my-blob" &&
892+
git -C "$P" add my-blob &&
893+
git -C "$P" commit -m x &&
894+
895+
configure_exclusion "$P" my-blob >h &&
896+
897+
git init http_child &&
898+
899+
GIT_TEST_SIDEBAND_ALL=1 \
900+
git -C http_child -c protocol.version=2 \
901+
-c fetch.uriprotocols=http,https \
902+
fetch "$HTTPD_URL/smart/http_parent"
903+
'
904+
884905
test_expect_success 'fetching with valid packfile URI but invalid hash fails' '
885906
P="$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&
886907
rm -rf "$P" http_child log &&

0 commit comments

Comments
 (0)