Skip to content

Commit 3ab0fb0

Browse files
jonathantanmygitster
authored andcommitted
sha1_file: set whence in storage-specific info fn
Move the setting of oi->whence to sha1_loose_object_info() and packed_object_info(). This allows sha1_object_info_extended() to not need to know about the delta base cache. This will be useful during a future refactoring in which packfile-related functions, including the handling of the delta base cache, will be moved to a separate file. Signed-off-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 4274c69 commit 3ab0fb0

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

sha1_file.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2444,6 +2444,9 @@ int packed_object_info(struct packed_git *p, off_t obj_offset,
24442444
hashclr(oi->delta_base_sha1);
24452445
}
24462446

2447+
oi->whence = in_delta_base_cache(p, obj_offset) ? OI_DBCACHED :
2448+
OI_PACKED;
2449+
24472450
out:
24482451
unuse_pack(&w_curs);
24492452
return type;
@@ -2973,6 +2976,7 @@ static int sha1_loose_object_info(const unsigned char *sha1,
29732976
if (oi->sizep == &size_scratch)
29742977
oi->sizep = NULL;
29752978
strbuf_release(&hdrbuf);
2979+
oi->whence = OI_LOOSE;
29762980
return (status < 0) ? status : 0;
29772981
}
29782982

@@ -3010,10 +3014,8 @@ int sha1_object_info_extended(const unsigned char *sha1, struct object_info *oi,
30103014

30113015
if (!find_pack_entry(real, &e)) {
30123016
/* Most likely it's a loose object. */
3013-
if (!sha1_loose_object_info(real, oi, flags)) {
3014-
oi->whence = OI_LOOSE;
3017+
if (!sha1_loose_object_info(real, oi, flags))
30153018
return 0;
3016-
}
30173019

30183020
/* Not a loose object; someone else may have just packed it. */
30193021
if (flags & OBJECT_INFO_QUICK) {
@@ -3036,10 +3038,7 @@ int sha1_object_info_extended(const unsigned char *sha1, struct object_info *oi,
30363038
if (rtype < 0) {
30373039
mark_bad_packed_object(e.p, real);
30383040
return sha1_object_info_extended(real, oi, 0);
3039-
} else if (in_delta_base_cache(e.p, e.offset)) {
3040-
oi->whence = OI_DBCACHED;
3041-
} else {
3042-
oi->whence = OI_PACKED;
3041+
} else if (oi->whence == OI_PACKED) {
30433042
oi->u.packed.offset = e.offset;
30443043
oi->u.packed.pack = e.p;
30453044
oi->u.packed.is_delta = (rtype == OBJ_REF_DELTA ||

0 commit comments

Comments
 (0)