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 <jonathantanmy@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jonathan Tan committed Mar 14, 2018 at 11:42 UTC 98a2ea46c2dedf45b5a94335462547a5d78a68e2
2 files changed +22 -2
fetch-pack.c
+11 -2
@@ -886,8 +886,17 @@ static int get_pack(struct fetch_pack_args *args,
886 ? fetch_fsck_objects
887 : transfer_fsck_objects >= 0
888 ? 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 + }
900
901 cmd.in = demux.out;
902 cmd.git_cmd = 1;
t/t5616-partial-clone.sh
+11
@@ -143,4 +143,15 @@ test_expect_success 'manual prefetch of missing objects' '
143 test_line_count = 0 observed.oids
144 '
145
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 +
157 test_done