From: Jeff King <peff@peff.net>
To: git@vger.kernel.org
Cc: Jonathan Tan <jonathantanmy@google.com>
Subject: [PATCH 1/7] for_each_*_object: store flag definitions in a single location
Date: Fri, 10 Aug 2018 19:09:06 -0400 [thread overview]
Message-ID: <20180810230906.GA19875@sigill.intra.peff.net> (raw)
In-Reply-To: <20180810230729.GA19090@sigill.intra.peff.net>
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>
---
Arguably, all of these for_each_*_object() functions should stay
together. Even though some are related to packfiles and some to loose,
they are meant to be a unified API. So I'd be fine to do that on top,
but this at least reduces the chance of a mistake in the meantime.
cache.h | 13 ++++++++++++-
packfile.h | 8 ++------
2 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/cache.h b/cache.h
index 8dc7134f00..4187238ecf 100644
--- a/cache.h
+++ b/cache.h
@@ -1623,12 +1623,23 @@ int for_each_loose_file_in_objdir_buf(struct strbuf *path,
each_loose_subdir_fn subdir_cb,
void *data);
+/*
+ * Flags for for_each_*_object(), including for_each_loose below and
+ * for_each_packed in packfile.h.
+ */
+enum for_each_object_flags {
+ /* Iterate only over local objects, not alternates. */
+ FOR_EACH_OBJECT_LOCAL_ONLY = (1<<0),
+
+ /* Only iterate over packs obtained from the promisor remote. */
+ FOR_EACH_OBJECT_PROMISOR_ONLY = (1<<1),
+};
+
/*
* Iterate over loose objects in both the local
* repository and any alternates repositories (unless the
* LOCAL_ONLY flag is set).
*/
-#define FOR_EACH_OBJECT_LOCAL_ONLY 0x1
extern int for_each_loose_object(each_loose_object_fn, void *, unsigned flags);
/*
diff --git a/packfile.h b/packfile.h
index cc7eaffe1b..6ddc6a2e91 100644
--- a/packfile.h
+++ b/packfile.h
@@ -148,15 +148,11 @@ extern int has_object_pack(const struct object_id *oid);
extern int has_pack_index(const unsigned char *sha1);
-/*
- * Only iterate over packs obtained from the promisor remote.
- */
-#define FOR_EACH_OBJECT_PROMISOR_ONLY 2
-
/*
* Iterate over packed objects in both the local
* repository and any alternates repositories (unless the
- * FOR_EACH_OBJECT_LOCAL_ONLY flag, defined in cache.h, is set).
+ * FOR_EACH_OBJECT_LOCAL_ONLY flag is set). See cache.h for the complete list
+ * of flags.
*/
typedef int each_packed_object_fn(const struct object_id *oid,
struct packed_git *pack,
--
2.18.0.1058.g7433f71063
next prev parent reply other threads:[~2018-08-10 23:09 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-10 23:07 [PATCH 0/7] speeding up cat-file by reordering object access Jeff King
2018-08-10 23:09 ` Jeff King [this message]
2018-08-10 23:27 ` [PATCH 1/7] for_each_*_object: store flag definitions in a single location Stefan Beller
2018-08-10 23:31 ` Jeff King
2018-08-10 23:33 ` Jeff King
2018-08-10 23:39 ` Stefan Beller
2018-08-11 0:33 ` Jeff King
2018-08-10 23:09 ` [PATCH 2/7] for_each_*_object: take flag arguments as enum Jeff King
2018-08-10 23:11 ` [PATCH 3/7] for_each_*_object: give more comprehensive docstrings Jeff King
2018-08-10 23:15 ` [PATCH 4/7] for_each_packed_object: support iterating in pack-order Jeff King
2018-08-15 13:28 ` Derrick Stolee
2018-08-16 17:36 ` Jeff King
2018-08-10 23:16 ` [PATCH 5/7] t1006: test cat-file --batch-all-objects with duplicates Jeff King
2018-08-10 23:17 ` [PATCH 6/7] cat-file: rename batch_{loose,packed}_object callbacks Jeff King
2018-08-10 23:24 ` [PATCH 7/7] cat-file: support "unordered" output for --batch-all-objects Jeff King
2018-08-13 18:45 ` [PATCH 0/7] speeding up cat-file by reordering object access Jonathan Tan
2018-08-14 18:13 ` [PATCH 0/4] finishing touches on jk/for-each-object-iteration Jeff King
2018-08-14 18:14 ` [PATCH 1/4] cat-file: use oidset check-and-insert Jeff King
2018-08-14 18:18 ` [PATCH 2/4] cat-file: split batch "buf" into two variables Jeff King
2018-08-14 18:20 ` [PATCH 3/4] cat-file: use a single strbuf for all output Jeff King
2018-08-14 19:30 ` René Scharfe
2018-08-14 19:39 ` Jeff King
2018-08-14 18:21 ` [PATCH 4/4] for_each_*_object: move declarations to object-store.h Jeff King
2018-08-15 14:05 ` [PATCH 0/7] speeding up cat-file by reordering object access Derrick Stolee
2018-08-16 17:39 ` Jeff King
2018-08-16 18:52 ` Junio C Hamano
2018-08-16 19:45 ` Jeff King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180810230906.GA19875@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=jonathantanmy@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).