Skip to content

Commit 31f5256

Browse files
derrickstoleegitster
authored andcommitted
sha1-file: split OBJECT_INFO_FOR_PREFETCH
The OBJECT_INFO_FOR_PREFETCH bitflag was added to sha1-file.c in 0f4a4fb (sha1-file: support OBJECT_INFO_FOR_PREFETCH, 2019-03-29) and is used to prevent the fetch_objects() method when enabled. However, there is a problem with the current use. The definition of OBJECT_INFO_FOR_PREFETCH is given by adding 32 to OBJECT_INFO_QUICK. This is clearly stated above the definition (in a comment) that this is so OBJECT_INFO_FOR_PREFETCH implies OBJECT_INFO_QUICK. The problem is that using "flag & OBJECT_INFO_FOR_PREFETCH" means that OBJECT_INFO_QUICK also implies OBJECT_INFO_FOR_PREFETCH. Split out the single bit from OBJECT_INFO_FOR_PREFETCH into a new OBJECT_INFO_SKIP_FETCH_OBJECT as the single bit and keep OBJECT_INFO_FOR_PREFETCH as the union of two flags. This allows a clearer use of flag checking while also keeping the implication of OBJECT_INFO_QUICK. Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0f4a4fb commit 31f5256

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

object-store.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,10 +282,14 @@ struct object_info {
282282
#define OBJECT_INFO_IGNORE_LOOSE 16
283283
/*
284284
* Do not attempt to fetch the object if missing (even if fetch_is_missing is
285-
* nonzero). This is meant for bulk prefetching of missing blobs in a partial
286-
* clone. Implies OBJECT_INFO_QUICK.
285+
* nonzero).
287286
*/
288-
#define OBJECT_INFO_FOR_PREFETCH (32 + OBJECT_INFO_QUICK)
287+
#define OBJECT_INFO_SKIP_FETCH_OBJECT 32
288+
/*
289+
* This is meant for bulk prefetching of missing blobs in a partial
290+
* clone. Implies OBJECT_INFO_SKIP_FETCH_OBJECT and OBJECT_INFO_QUICK
291+
*/
292+
#define OBJECT_INFO_FOR_PREFETCH (OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_QUICK)
289293

290294
int oid_object_info_extended(struct repository *r,
291295
const struct object_id *,

sha1-file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1371,7 +1371,7 @@ int oid_object_info_extended(struct repository *r, const struct object_id *oid,
13711371
/* Check if it is a missing object */
13721372
if (fetch_if_missing && repository_format_partial_clone &&
13731373
!already_retried && r == the_repository &&
1374-
!(flags & OBJECT_INFO_FOR_PREFETCH)) {
1374+
!(flags & OBJECT_INFO_SKIP_FETCH_OBJECT)) {
13751375
/*
13761376
* TODO Investigate having fetch_object() return
13771377
* TODO error/success and stopping the music here.

0 commit comments

Comments
 (0)