diff: refactor object read
Refactor the object reads in diff_populate_filespec() to have the first object read not be in an if/else branch, because in a future patch, a retry will be added to that first object read. Signed-off-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
1c37e86ab2
commit
c14b6f83ec
27
diff.c
27
diff.c
@ -4023,12 +4023,22 @@ int diff_populate_filespec(struct repository *r,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
enum object_type type;
|
struct object_info info = {
|
||||||
|
.sizep = &s->size
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!(size_only || check_binary))
|
||||||
|
/*
|
||||||
|
* Set contentp, since there is no chance that merely
|
||||||
|
* the size is sufficient.
|
||||||
|
*/
|
||||||
|
info.contentp = &s->data;
|
||||||
|
|
||||||
|
if (oid_object_info_extended(r, &s->oid, &info,
|
||||||
|
OBJECT_INFO_LOOKUP_REPLACE))
|
||||||
|
die("unable to read %s", oid_to_hex(&s->oid));
|
||||||
|
|
||||||
if (size_only || check_binary) {
|
if (size_only || check_binary) {
|
||||||
type = oid_object_info(r, &s->oid, &s->size);
|
|
||||||
if (type < 0)
|
|
||||||
die("unable to read %s",
|
|
||||||
oid_to_hex(&s->oid));
|
|
||||||
if (size_only)
|
if (size_only)
|
||||||
return 0;
|
return 0;
|
||||||
if (s->size > big_file_threshold && s->is_binary == -1) {
|
if (s->size > big_file_threshold && s->is_binary == -1) {
|
||||||
@ -4036,9 +4046,12 @@ int diff_populate_filespec(struct repository *r,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s->data = repo_read_object_file(r, &s->oid, &type, &s->size);
|
if (!info.contentp) {
|
||||||
if (!s->data)
|
info.contentp = &s->data;
|
||||||
|
if (oid_object_info_extended(r, &s->oid, &info,
|
||||||
|
OBJECT_INFO_LOOKUP_REPLACE))
|
||||||
die("unable to read %s", oid_to_hex(&s->oid));
|
die("unable to read %s", oid_to_hex(&s->oid));
|
||||||
|
}
|
||||||
s->should_free = 1;
|
s->should_free = 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user