@matheusbsbs / matheus-bagliano / commits / 3318238db9
Fork 0

apply: do not lazy fetch when applying binary

When applying a binary patch, as an optimization, "apply" checks if the postimage is already present. During this fetch, it is perfectly expected for the postimage not to be present, so there is no need to lazy-fetch missing objects. Teach "apply" not to lazy-fetch in this case. Signed-off-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jonathan Tan committed Aug 5, 2020 at 16:06 UTC 3318238db9498749db6d4feb7a804d366eccfa82
2 files changed +17 -1
apply.c
+1 -1
@@ -3178,7 +3178,7 @@ static int apply_binary(struct apply_state *state,
3178 return 0; /* deletion patch */
3179 }
3180
3181 - if (has_object_file(&oid)) {
3181 + if (has_object(the_repository, &oid, 0)) {
3182 /* We already have the postimage */
3183 enum object_type type;
3184 unsigned long size;
t/t4150-am.sh
+16
@@ -1133,4 +1133,20 @@ test_expect_success 'am and .gitattibutes' '
1133 )
1134 '
1135
1136 +test_expect_success 'apply binary blob in partial clone' '
1137 + printf "\\000" >binary &&
1138 + git add binary &&
1139 + git commit -m "binary blob" &&
1140 + git format-patch --stdout -m HEAD^ >patch &&
1141 +
1142 + test_create_repo server &&
1143 + test_config -C server uploadpack.allowfilter 1 &&
1144 + test_config -C server uploadpack.allowanysha1inwant 1 &&
1145 + git clone --filter=blob:none "file://$(pwd)/server" client &&
1146 + test_when_finished "rm -rf client" &&
1147 +
1148 + # Exercise to make sure that it works
1149 + git -C client am ../patch
1150 +'
1151 +
1152 test_done