Skip to content

Commit

Permalink
apply: do not lazy fetch when applying binary
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
jonathantanmy authored and gitster committed Aug 6, 2020
1 parent 1d8d9cb commit 3318238
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion apply.c
Original file line number Diff line number Diff line change
Expand Up @@ -3178,7 +3178,7 @@ static int apply_binary(struct apply_state *state,
return 0; /* deletion patch */
}

if (has_object_file(&oid)) {
if (has_object(the_repository, &oid, 0)) {
/* We already have the postimage */
enum object_type type;
unsigned long size;
Expand Down
16 changes: 16 additions & 0 deletions t/t4150-am.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1133,4 +1133,20 @@ test_expect_success 'am and .gitattibutes' '
)
'

test_expect_success 'apply binary blob in partial clone' '
printf "\\000" >binary &&
git add binary &&
git commit -m "binary blob" &&
git format-patch --stdout -m HEAD^ >patch &&
test_create_repo server &&
test_config -C server uploadpack.allowfilter 1 &&
test_config -C server uploadpack.allowanysha1inwant 1 &&
git clone --filter=blob:none "file://$(pwd)/server" client &&
test_when_finished "rm -rf client" &&
# Exercise to make sure that it works
git -C client am ../patch
'

test_done

0 comments on commit 3318238

Please sign in to comment.