Skip to content

Commit 98a2ea4

Browse files
jonathantanmygitster
authored andcommitted
fetch-pack: do not check links for partial fetch
When doing a partial clone or fetch with 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 when doing a partial clone or fetch. Signed-off-by: Jonathan Tan <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ffb2c0f commit 98a2ea4

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

fetch-pack.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -886,8 +886,17 @@ static int get_pack(struct fetch_pack_args *args,
886886
? fetch_fsck_objects
887887
: transfer_fsck_objects >= 0
888888
? transfer_fsck_objects
889-
: 0)
890-
argv_array_push(&cmd.args, "--strict");
889+
: 0) {
890+
if (args->from_promisor)
891+
/*
892+
* We cannot use --strict in index-pack because it
893+
* checks both broken objects and links, but we only
894+
* want to check for broken objects.
895+
*/
896+
argv_array_push(&cmd.args, "--fsck-objects");
897+
else
898+
argv_array_push(&cmd.args, "--strict");
899+
}
891900

892901
cmd.in = demux.out;
893902
cmd.git_cmd = 1;

t/t5616-partial-clone.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,15 @@ test_expect_success 'manual prefetch of missing objects' '
143143
test_line_count = 0 observed.oids
144144
'
145145

146+
test_expect_success 'partial clone with transfer.fsckobjects=1 uses index-pack --fsck-objects' '
147+
git init src &&
148+
test_commit -C src x &&
149+
test_config -C src uploadpack.allowfilter 1 &&
150+
test_config -C src uploadpack.allowanysha1inwant 1 &&
151+
152+
GIT_TRACE="$(pwd)/trace" git -c transfer.fsckobjects=1 \
153+
clone --filter="blob:none" "file://$(pwd)/src" dst &&
154+
grep "git index-pack.*--fsck-objects" trace
155+
'
156+
146157
test_done

0 commit comments

Comments
 (0)