Skip to content

Commit 3318238

Browse files
jonathantanmygitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1d8d9cb commit 3318238

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

apply.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3178,7 +3178,7 @@ static int apply_binary(struct apply_state *state,
31783178
return 0; /* deletion patch */
31793179
}
31803180

3181-
if (has_object_file(&oid)) {
3181+
if (has_object(the_repository, &oid, 0)) {
31823182
/* We already have the postimage */
31833183
enum object_type type;
31843184
unsigned long size;

t/t4150-am.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,4 +1133,20 @@ test_expect_success 'am and .gitattibutes' '
11331133
)
11341134
'
11351135

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+
11361152
test_done

0 commit comments

Comments
 (0)