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>
Jeff King committed
Aug 10, 2018 at 19:09 UTC
202e7f1e161b5bce6587d1a696843ead10a8b477
2 files changed
+14
-7
cache.h
+12
-1
@@ -1623,12 +1623,23 @@ int for_each_loose_file_in_objdir_buf(struct strbuf *path,
1623
each_loose_subdir_fn subdir_cb,
1624
void *data);
1625
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
+
1638
/*
1639
* Iterate over loose objects in both the local
1640
* repository and any alternates repositories (unless the
1641
* LOCAL_ONLY flag is set).
1642
*/
1631
-#define FOR_EACH_OBJECT_LOCAL_ONLY 0x1
1643
extern int for_each_loose_object(each_loose_object_fn, void *, unsigned flags);
1644
1645
/*
packfile.h
+2
-6
@@ -148,15 +148,11 @@ extern int has_object_pack(const struct object_id *oid);
148
149
extern int has_pack_index(const unsigned char *sha1);
150
151
-/*
152
- * Only iterate over packs obtained from the promisor remote.
153
- */
154
-#define FOR_EACH_OBJECT_PROMISOR_ONLY 2
155
-
151
/*
152
* Iterate over packed objects in both the local
153
* 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.
156
*/
157
typedef int each_packed_object_fn(const struct object_id *oid,
158
struct packed_git *pack,