Skip to content

Commit 0bd96be

Browse files
jonathantanmygitster
authored andcommitted
fetch-pack: make packfile URIs work with transfer.fsckobjects
When fetching with packfile URIs and transfer.fsckobjects=1, use the --fsck-objects instead of the --strict flag when invoking index-pack so that links are not checked, only objects. This is because incomplete links are expected. (A subsequent connectivity check will be done when all the packs have been downloaded regardless of whether transfer.fsckobjects is set.) This is similar to 98a2ea4 ("fetch-pack: do not check links for partial fetch", 2018-03-15), but for packfile URIs instead of partial clones. Signed-off-by: Jonathan Tan <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ece9aea commit 0bd96be

File tree

2 files changed

+54
-1
lines changed

2 files changed

+54
-1
lines changed

fetch-pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -896,7 +896,7 @@ static int get_pack(struct fetch_pack_args *args,
896896
: transfer_fsck_objects >= 0
897897
? transfer_fsck_objects
898898
: 0) {
899-
if (args->from_promisor)
899+
if (args->from_promisor || !only_packfile)
900900
/*
901901
* We cannot use --strict in index-pack because it
902902
* checks both broken objects and links, but we only

t/t5702-protocol-v2.sh

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -883,6 +883,59 @@ test_expect_success 'fetching with valid packfile URI but invalid hash fails' '
883883
test_i18ngrep "pack downloaded from.*does not match expected hash" err
884884
'
885885

886+
test_expect_success 'packfile-uri with transfer.fsckobjects' '
887+
P="$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&
888+
rm -rf "$P" http_child log &&
889+
890+
git init "$P" &&
891+
git -C "$P" config "uploadpack.allowsidebandall" "true" &&
892+
893+
echo my-blob >"$P/my-blob" &&
894+
git -C "$P" add my-blob &&
895+
git -C "$P" commit -m x &&
896+
897+
configure_exclusion "$P" my-blob >h &&
898+
899+
sane_unset GIT_TEST_SIDEBAND_ALL &&
900+
git -c protocol.version=2 -c transfer.fsckobjects=1 \
901+
-c fetch.uriprotocols=http,https \
902+
clone "$HTTPD_URL/smart/http_parent" http_child &&
903+
904+
# Ensure that there are exactly 4 files (2 .pack and 2 .idx).
905+
ls http_child/.git/objects/pack/* >filelist &&
906+
test_line_count = 4 filelist
907+
'
908+
909+
test_expect_success 'packfile-uri with transfer.fsckobjects fails on bad object' '
910+
P="$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&
911+
rm -rf "$P" http_child log &&
912+
913+
git init "$P" &&
914+
git -C "$P" config "uploadpack.allowsidebandall" "true" &&
915+
916+
cat >bogus-commit <<-EOF &&
917+
tree $EMPTY_TREE
918+
author Bugs Bunny 1234567890 +0000
919+
committer Bugs Bunny <[email protected]> 1234567890 +0000
920+
921+
This commit object intentionally broken
922+
EOF
923+
BOGUS=$(git -C "$P" hash-object -t commit -w --stdin <bogus-commit) &&
924+
git -C "$P" branch bogus-branch "$BOGUS" &&
925+
926+
echo my-blob >"$P/my-blob" &&
927+
git -C "$P" add my-blob &&
928+
git -C "$P" commit -m x &&
929+
930+
configure_exclusion "$P" my-blob >h &&
931+
932+
sane_unset GIT_TEST_SIDEBAND_ALL &&
933+
test_must_fail git -c protocol.version=2 -c transfer.fsckobjects=1 \
934+
-c fetch.uriprotocols=http,https \
935+
clone "$HTTPD_URL/smart/http_parent" http_child 2>error &&
936+
test_i18ngrep "invalid author/committer line - missing email" error
937+
'
938+
886939
# DO NOT add non-httpd-specific tests here, because the last part of this
887940
# test script is only executed when httpd is available and enabled.
888941

0 commit comments

Comments
 (0)