Skip to content

Commit 202e7f1

Browse files
peffgitster
authored andcommitted
for_each_*_object: store flag definitions in a single location
These flags were split between cache.h and packfile.h, because some of the flags apply only to packs. However, they share a single numeric namespace, since both are respected for the packed variant. Let's make sure they're defined together so that nobody accidentally adds a new flag in one location that duplicates the other. While we're here, let's also put them in an enum (which helps debugger visibility) and use "(1<<n)" rather than counting powers of 2 manually. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 1d89318 commit 202e7f1

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

cache.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1623,12 +1623,23 @@ int for_each_loose_file_in_objdir_buf(struct strbuf *path,
16231623
each_loose_subdir_fn subdir_cb,
16241624
void *data);
16251625

1626+
/*
1627+
* Flags for for_each_*_object(), including for_each_loose below and
1628+
* for_each_packed in packfile.h.
1629+
*/
1630+
enum for_each_object_flags {
1631+
/* Iterate only over local objects, not alternates. */
1632+
FOR_EACH_OBJECT_LOCAL_ONLY = (1<<0),
1633+
1634+
/* Only iterate over packs obtained from the promisor remote. */
1635+
FOR_EACH_OBJECT_PROMISOR_ONLY = (1<<1),
1636+
};
1637+
16261638
/*
16271639
* Iterate over loose objects in both the local
16281640
* repository and any alternates repositories (unless the
16291641
* LOCAL_ONLY flag is set).
16301642
*/
1631-
#define FOR_EACH_OBJECT_LOCAL_ONLY 0x1
16321643
extern int for_each_loose_object(each_loose_object_fn, void *, unsigned flags);
16331644

16341645
/*

packfile.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,15 +148,11 @@ extern int has_object_pack(const struct object_id *oid);
148148

149149
extern int has_pack_index(const unsigned char *sha1);
150150

151-
/*
152-
* Only iterate over packs obtained from the promisor remote.
153-
*/
154-
#define FOR_EACH_OBJECT_PROMISOR_ONLY 2
155-
156151
/*
157152
* Iterate over packed objects in both the local
158153
* repository and any alternates repositories (unless the
159-
* FOR_EACH_OBJECT_LOCAL_ONLY flag, defined in cache.h, is set).
154+
* FOR_EACH_OBJECT_LOCAL_ONLY flag is set). See cache.h for the complete list
155+
* of flags.
160156
*/
161157
typedef int each_packed_object_fn(const struct object_id *oid,
162158
struct packed_git *pack,

0 commit comments

Comments
 (0)