{"thread":{"id":"65401","subject":"[PATCH 0/6] odb: small set of cleanups","startedAt":"2026-03-31T23:57:54Z","lastAt":"2026-03-31T23:58:10Z","messageCount":7,"participants":["Patrick Steinhardt"],"isPatch":true,"patchVersion":1,"patchTotal":6},"messages":[{"id":"540600","messageId":"20260401-pks-odb-cleanups-v1-0-89adba9ada68@pks.im","threadId":"65401","inReplyTo":null,"subject":"[PATCH 0/6] odb: small set of cleanups","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-03-31T23:57:45Z","receivedAt":"2026-03-31T23:57:54Z","isPatch":true,"body":"Hi,\n\nthis patch series contains a small set of cleanups that I have\naccumulated over time, but that didn't fit into any of the other patch\nseries I've sent out recently.\n\nThis patch is based on 270e10ad6d (The 23rd batch, 2026-03-30) with\nps/odb-generic-object-name-handling at 83869e15fa (odb: introduce\ngeneric `odb_find_abbrev_len()`, 2026-03-20) merged into it.\n\nThanks!\n\nPatrick\n\n---\nPatrick Steinhardt (6):\n      CodingGuidelines: document our style for flags\n      treewide: use enum for `odb_for_each_object()` flags\n      odb: rename `odb_write_object()` flags\n      odb: use enum for `odb_write_object` flags\n      odb: rename `odb_has_object()` flags\n      odb: drop unneeded headers and forward decls\n\n Documentation/CodingGuidelines | 12 ++++++++++++\n builtin/cat-file.c             |  2 +-\n builtin/fetch.c                |  4 ++--\n builtin/fsck.c                 |  2 +-\n builtin/index-pack.c           |  2 +-\n builtin/receive-pack.c         |  2 +-\n builtin/remote.c               |  2 +-\n builtin/show-ref.c             |  2 +-\n builtin/unpack-objects.c       |  2 +-\n cache-tree.c                   | 10 +++++-----\n fetch-pack.c                   |  4 ++--\n http-push.c                    |  8 ++++----\n http-walker.c                  |  4 ++--\n list-objects.c                 |  2 +-\n notes.c                        |  2 +-\n object-file.c                  |  9 +++++----\n object-file.h                  |  3 ++-\n odb.c                          | 10 +++++-----\n odb.h                          | 30 ++++++++++++------------------\n odb/source-files.c             |  2 +-\n odb/source.h                   |  4 ++--\n packfile.c                     |  2 +-\n packfile.h                     |  2 +-\n reflog.c                       |  2 +-\n refs.c                         |  2 +-\n remote.c                       |  2 +-\n shallow.c                      |  6 +++---\n walker.c                       |  2 +-\n 28 files changed, 72 insertions(+), 64 deletions(-)\n\n\n---\nbase-commit: 04728db51b447d5e2d1a2748f7c70d30dbe5eb7a\nchange-id: 20260320-pks-odb-cleanups-70aebd8d9998\n\n"},{"id":"540601","messageId":"20260401-pks-odb-cleanups-v1-1-89adba9ada68@pks.im","threadId":"65401","inReplyTo":"20260401-pks-odb-cleanups-v1-0-89adba9ada68@pks.im","subject":"[PATCH 1/6] CodingGuidelines: document our style for flags","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-03-31T23:57:46Z","receivedAt":"2026-03-31T23:57:55Z","isPatch":true,"body":"We have recently iterated a bit on our style for flags. Document this.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n Documentation/CodingGuidelines | 12 ++++++++++++\n 1 file changed, 12 insertions(+)\n\ndiff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines\nindex b8670751f5..4992e52093 100644\n--- a/Documentation/CodingGuidelines\n+++ b/Documentation/CodingGuidelines\n@@ -668,6 +668,18 @@ For C programs:\n    unsigned other_field:1;\n    unsigned field_with_longer_name:1;\n \n+ - When a function `F` accepts flags, those flags should be defined as `enum\n+   F_flags`. Individual flag definitions should start with `F` and be in\n+   all-uppercase letters. Flag values should be represented via bit shifts.\n+   E.g.\n+\n+        enum frobnicate_flags {\n+                FROBNICATE_FOO = (1 << 0),\n+                FROBNICATE_BAR = (1 << 1),\n+        };\n+\n+        int frobnicate(enum frobnicate_flags flags);\n+\n  - Array names should be named in the singular form if the individual items are\n    subject of use. E.g.:\n \n\n-- \n2.53.0.1185.g05d4b7b318.dirty\n\n"},{"id":"540602","messageId":"20260401-pks-odb-cleanups-v1-2-89adba9ada68@pks.im","threadId":"65401","inReplyTo":"20260401-pks-odb-cleanups-v1-0-89adba9ada68@pks.im","subject":"[PATCH 2/6] treewide: use enum for `odb_for_each_object()` flags","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-03-31T23:57:47Z","receivedAt":"2026-03-31T23:57:59Z","isPatch":true,"body":"We've got a couple of callsites where we pass `odb_for_each_object()`\nflags, but accept an `unsigned` flags field instead of the corresponding\nenum. Adapt these to accept the enum type instead.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n odb.c      | 2 +-\n odb.h      | 2 +-\n packfile.c | 2 +-\n packfile.h | 2 +-\n 4 files changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/odb.c b/odb.c\nindex 3f94a53df1..9a11c60048 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -922,7 +922,7 @@ int odb_for_each_object(struct object_database *odb,\n \t\t\tconst struct object_info *request,\n \t\t\todb_for_each_object_cb cb,\n \t\t\tvoid *cb_data,\n-\t\t\tunsigned flags)\n+\t\t\tenum odb_for_each_object_flags flags)\n {\n \tstruct odb_for_each_object_options opts = {\n \t\t.flags = flags,\ndiff --git a/odb.h b/odb.h\nindex 984bafca9d..09affaf6a5 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -522,7 +522,7 @@ int odb_for_each_object(struct object_database *odb,\n \t\t\tconst struct object_info *request,\n \t\t\todb_for_each_object_cb cb,\n \t\t\tvoid *cb_data,\n-\t\t\tunsigned flags);\n+\t\t\tenum odb_for_each_object_flags flags);\n \n enum odb_count_objects_flags {\n \t/*\ndiff --git a/packfile.c b/packfile.c\nindex ee9c7ea1d1..5d3b772973 100644\n--- a/packfile.c\n+++ b/packfile.c\n@@ -2299,7 +2299,7 @@ int has_object_kept_pack(struct repository *r, const struct object_id *oid,\n \n int for_each_object_in_pack(struct packed_git *p,\n \t\t\t    each_packed_object_fn cb, void *data,\n-\t\t\t    unsigned flags)\n+\t\t\t    enum odb_for_each_object_flags flags)\n {\n \tuint32_t i;\n \tint r = 0;\ndiff --git a/packfile.h b/packfile.h\nindex 45b35973f0..3eb10d6b65 100644\n--- a/packfile.h\n+++ b/packfile.h\n@@ -352,7 +352,7 @@ typedef int each_packed_object_fn(const struct object_id *oid,\n \t\t\t\t  void *data);\n int for_each_object_in_pack(struct packed_git *p,\n \t\t\t    each_packed_object_fn, void *data,\n-\t\t\t    unsigned flags);\n+\t\t\t    enum odb_for_each_object_flags flags);\n \n /*\n  * Iterate through all packed objects in the given packfile store and invoke\n\n-- \n2.53.0.1185.g05d4b7b318.dirty\n\n"},{"id":"540603","messageId":"20260401-pks-odb-cleanups-v1-3-89adba9ada68@pks.im","threadId":"65401","inReplyTo":"20260401-pks-odb-cleanups-v1-0-89adba9ada68@pks.im","subject":"[PATCH 3/6] odb: rename `odb_write_object()` flags","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-03-31T23:57:48Z","receivedAt":"2026-03-31T23:58:02Z","isPatch":true,"body":"Rename `odb_write_object()` flags to be properly prefixed with the\nfunction name.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n cache-tree.c  | 2 +-\n object-file.c | 4 ++--\n odb.h         | 4 ++--\n 3 files changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/cache-tree.c b/cache-tree.c\nindex 60bcc07c3b..60059edfb0 100644\n--- a/cache-tree.c\n+++ b/cache-tree.c\n@@ -456,7 +456,7 @@ static int update_one(struct cache_tree *it,\n \t\thash_object_file(the_hash_algo, buffer.buf, buffer.len,\n \t\t\t\t OBJ_TREE, &it->oid);\n \t} else if (odb_write_object_ext(the_repository->objects, buffer.buf, buffer.len, OBJ_TREE,\n-\t\t\t\t\t&it->oid, NULL, flags & WRITE_TREE_SILENT ? WRITE_OBJECT_SILENT : 0)) {\n+\t\t\t\t\t&it->oid, NULL, flags & WRITE_TREE_SILENT ? ODB_WRITE_OBJECT_SILENT : 0)) {\n \t\tstrbuf_release(&buffer);\n \t\treturn -1;\n \t}\ndiff --git a/object-file.c b/object-file.c\nindex 4f77ce0982..db1a420ab6 100644\n--- a/object-file.c\n+++ b/object-file.c\n@@ -909,7 +909,7 @@ static int start_loose_object_common(struct odb_source *source,\n \n \tfd = create_tmpfile(source->odb->repo, tmp_file, filename);\n \tif (fd < 0) {\n-\t\tif (flags & WRITE_OBJECT_SILENT)\n+\t\tif (flags & ODB_WRITE_OBJECT_SILENT)\n \t\t\treturn -1;\n \t\telse if (errno == EACCES)\n \t\t\treturn error(_(\"insufficient permission for adding \"\n@@ -1042,7 +1042,7 @@ static int write_loose_object(struct odb_source *source,\n \t\tutb.actime = mtime;\n \t\tutb.modtime = mtime;\n \t\tif (utime(tmp_file.buf, &utb) < 0 &&\n-\t\t    !(flags & WRITE_OBJECT_SILENT))\n+\t\t    !(flags & ODB_WRITE_OBJECT_SILENT))\n \t\t\twarning_errno(_(\"failed utime() on %s\"), tmp_file.buf);\n \t}\n \ndiff --git a/odb.h b/odb.h\nindex 09affaf6a5..083c25609e 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -568,12 +568,12 @@ enum {\n \t * changes that so that the object will be written as a loose object\n \t * and persisted.\n \t */\n-\tWRITE_OBJECT_PERSIST = (1 << 0),\n+\tODB_WRITE_OBJECT_PERSIST = (1 << 0),\n \n \t/*\n \t * Do not print an error in case something goes wrong.\n \t */\n-\tWRITE_OBJECT_SILENT = (1 << 1),\n+\tODB_WRITE_OBJECT_SILENT = (1 << 1),\n };\n \n /*\n\n-- \n2.53.0.1185.g05d4b7b318.dirty\n\n"},{"id":"540604","messageId":"20260401-pks-odb-cleanups-v1-4-89adba9ada68@pks.im","threadId":"65401","inReplyTo":"20260401-pks-odb-cleanups-v1-0-89adba9ada68@pks.im","subject":"[PATCH 4/6] odb: use enum for `odb_write_object` flags","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-03-31T23:57:49Z","receivedAt":"2026-03-31T23:58:05Z","isPatch":true,"body":"We've got a couple of functions that accept `odb_write_object()` flags,\nbut all of them accept the flags as an `unsigned` integer. In fact, we\ndon't even have an `enum` for the flags field.\n\nIntroduce this `enum` and adapt functions accordingly according to our\ncoding style.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n object-file.c      | 3 ++-\n object-file.h      | 3 ++-\n odb.c              | 2 +-\n odb.h              | 4 ++--\n odb/source-files.c | 2 +-\n odb/source.h       | 4 ++--\n 6 files changed, 10 insertions(+), 8 deletions(-)\n\ndiff --git a/object-file.c b/object-file.c\nindex db1a420ab6..2146104de8 100644\n--- a/object-file.c\n+++ b/object-file.c\n@@ -1169,7 +1169,8 @@ int odb_source_loose_write_stream(struct odb_source *source,\n int odb_source_loose_write_object(struct odb_source *source,\n \t\t\t\t  const void *buf, unsigned long len,\n \t\t\t\t  enum object_type type, struct object_id *oid,\n-\t\t\t\t  struct object_id *compat_oid_in, unsigned flags)\n+\t\t\t\t  struct object_id *compat_oid_in,\n+\t\t\t\t  enum odb_write_object_flags flags)\n {\n \tconst struct git_hash_algo *algo = source->odb->repo->hash_algo;\n \tconst struct git_hash_algo *compat = source->odb->repo->compat_hash_algo;\ndiff --git a/object-file.h b/object-file.h\nindex 3686f182e4..5241b8dd5c 100644\n--- a/object-file.h\n+++ b/object-file.h\n@@ -68,7 +68,8 @@ int odb_source_loose_freshen_object(struct odb_source *source,\n int odb_source_loose_write_object(struct odb_source *source,\n \t\t\t\t  const void *buf, unsigned long len,\n \t\t\t\t  enum object_type type, struct object_id *oid,\n-\t\t\t\t  struct object_id *compat_oid_in, unsigned flags);\n+\t\t\t\t  struct object_id *compat_oid_in,\n+\t\t\t\t  enum odb_write_object_flags flags);\n \n int odb_source_loose_write_stream(struct odb_source *source,\n \t\t\t\t  struct odb_write_stream *stream, size_t len,\ndiff --git a/odb.c b/odb.c\nindex 9a11c60048..8220661356 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -1053,7 +1053,7 @@ int odb_write_object_ext(struct object_database *odb,\n \t\t\t enum object_type type,\n \t\t\t struct object_id *oid,\n \t\t\t struct object_id *compat_oid,\n-\t\t\t unsigned flags)\n+\t\t\t enum odb_write_object_flags flags)\n {\n \treturn odb_source_write_object(odb->sources, buf, len, type,\n \t\t\t\t       oid, compat_oid, flags);\ndiff --git a/odb.h b/odb.h\nindex 083c25609e..9aadc1177a 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -561,7 +561,7 @@ int odb_find_abbrev_len(struct object_database *odb,\n \t\t\tint min_len,\n \t\t\tunsigned *out);\n \n-enum {\n+enum odb_write_object_flags {\n \t/*\n \t * By default, `odb_write_object()` does not actually write anything\n \t * into the object store, but only computes the object ID. This flag\n@@ -589,7 +589,7 @@ int odb_write_object_ext(struct object_database *odb,\n \t\t\t enum object_type type,\n \t\t\t struct object_id *oid,\n \t\t\t struct object_id *compat_oid,\n-\t\t\t unsigned flags);\n+\t\t\t enum odb_write_object_flags flags);\n \n static inline int odb_write_object(struct object_database *odb,\n \t\t\t\t   const void *buf, unsigned long len,\ndiff --git a/odb/source-files.c b/odb/source-files.c\nindex 76797569de..b5abd20e97 100644\n--- a/odb/source-files.c\n+++ b/odb/source-files.c\n@@ -161,7 +161,7 @@ static int odb_source_files_write_object(struct odb_source *source,\n \t\t\t\t\t enum object_type type,\n \t\t\t\t\t struct object_id *oid,\n \t\t\t\t\t struct object_id *compat_oid,\n-\t\t\t\t\t unsigned flags)\n+\t\t\t\t\t enum odb_write_object_flags flags)\n {\n \treturn odb_source_loose_write_object(source, buf, len, type,\n \t\t\t\t\t     oid, compat_oid, flags);\ndiff --git a/odb/source.h b/odb/source.h\nindex a9d7d0b96f..f706e0608a 100644\n--- a/odb/source.h\n+++ b/odb/source.h\n@@ -197,7 +197,7 @@ struct odb_source {\n \t\t\t    enum object_type type,\n \t\t\t    struct object_id *oid,\n \t\t\t    struct object_id *compat_oid,\n-\t\t\t    unsigned flags);\n+\t\t\t    enum odb_write_object_flags flags);\n \n \t/*\n \t * This callback is expected to persist the given object stream into\n@@ -405,7 +405,7 @@ static inline int odb_source_write_object(struct odb_source *source,\n \t\t\t\t\t  enum object_type type,\n \t\t\t\t\t  struct object_id *oid,\n \t\t\t\t\t  struct object_id *compat_oid,\n-\t\t\t\t\t  unsigned flags)\n+\t\t\t\t\t  enum odb_write_object_flags flags)\n {\n \treturn source->write_object(source, buf, len, type, oid,\n \t\t\t\t    compat_oid, flags);\n\n-- \n2.53.0.1185.g05d4b7b318.dirty\n\n"},{"id":"540605","messageId":"20260401-pks-odb-cleanups-v1-5-89adba9ada68@pks.im","threadId":"65401","inReplyTo":"20260401-pks-odb-cleanups-v1-0-89adba9ada68@pks.im","subject":"[PATCH 5/6] odb: rename `odb_has_object()` flags","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-03-31T23:57:50Z","receivedAt":"2026-03-31T23:58:08Z","isPatch":true,"body":"Rename `odb_has_object()` flags to be properly prefixed with the\nfunction name.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/cat-file.c       | 2 +-\n builtin/fetch.c          | 4 ++--\n builtin/fsck.c           | 2 +-\n builtin/index-pack.c     | 2 +-\n builtin/receive-pack.c   | 2 +-\n builtin/remote.c         | 2 +-\n builtin/show-ref.c       | 2 +-\n builtin/unpack-objects.c | 2 +-\n cache-tree.c             | 8 ++++----\n fetch-pack.c             | 4 ++--\n http-push.c              | 8 ++++----\n http-walker.c            | 4 ++--\n list-objects.c           | 2 +-\n notes.c                  | 2 +-\n object-file.c            | 2 +-\n odb.c                    | 6 +++---\n odb.h                    | 8 ++++----\n reflog.c                 | 2 +-\n refs.c                   | 2 +-\n remote.c                 | 2 +-\n shallow.c                | 6 +++---\n walker.c                 | 2 +-\n 22 files changed, 38 insertions(+), 38 deletions(-)\n\ndiff --git a/builtin/cat-file.c b/builtin/cat-file.c\nindex cd13a3a89f..d9fbad5358 100644\n--- a/builtin/cat-file.c\n+++ b/builtin/cat-file.c\n@@ -161,7 +161,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)\n \n \tcase 'e':\n \t\tret = !odb_has_object(the_repository->objects, &oid,\n-\t\t\t\t      HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR);\n+\t\t\t\t      ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR);\n \t\tgoto cleanup;\n \n \tcase 'w':\ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex 4795b2a13c..a22c319467 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -946,7 +946,7 @@ static int update_local_ref(struct ref *ref,\n \tint fast_forward = 0;\n \n \tif (!odb_has_object(the_repository->objects, &ref->new_oid,\n-\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\t\t\t    ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR))\n \t\tdie(_(\"object %s not found\"), oid_to_hex(&ref->new_oid));\n \n \tif (oideq(&ref->old_oid, &ref->new_oid)) {\n@@ -1396,7 +1396,7 @@ static int check_exist_and_connected(struct ref *ref_map)\n \t */\n \tfor (r = rm; r; r = r->next) {\n \t\tif (!odb_has_object(the_repository->objects, &r->old_oid,\n-\t\t\t\t    HAS_OBJECT_RECHECK_PACKED))\n+\t\t\t\t    ODB_HAS_OBJECT_RECHECK_PACKED))\n \t\t\treturn -1;\n \t}\n \ndiff --git a/builtin/fsck.c b/builtin/fsck.c\nindex 9bab32effe..4bd0faeff1 100644\n--- a/builtin/fsck.c\n+++ b/builtin/fsck.c\n@@ -163,7 +163,7 @@ static int mark_object(struct object *obj, enum object_type type,\n \n \tif (!(obj->flags & HAS_OBJ)) {\n \t\tif (parent && !odb_has_object(the_repository->objects, &obj->oid,\n-\t\t\t\t\t      HAS_OBJECT_RECHECK_PACKED)) {\n+\t\t\t\t\t      ODB_HAS_OBJECT_RECHECK_PACKED)) {\n \t\t\tprintf_ln(_(\"broken link from %7s %s\\n\"\n \t\t\t\t    \"              to %7s %s\"),\n \t\t\t\t  printable_type(&parent->oid, parent->type),\ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex d1e47279a8..d96d0eb8cf 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -891,7 +891,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,\n \tif (startup_info->have_repository) {\n \t\tread_lock();\n \t\tcollision_test_needed = odb_has_object(the_repository->objects, oid,\n-\t\t\t\t\t\t       HAS_OBJECT_FETCH_PROMISOR);\n+\t\t\t\t\t\t       ODB_HAS_OBJECT_FETCH_PROMISOR);\n \t\tread_unlock();\n \t}\n \ndiff --git a/builtin/receive-pack.c b/builtin/receive-pack.c\nindex e34edff406..32b0223884 100644\n--- a/builtin/receive-pack.c\n+++ b/builtin/receive-pack.c\n@@ -1546,7 +1546,7 @@ static const char *update(struct command *cmd, struct shallow_info *si)\n \n \tif (!is_null_oid(new_oid) &&\n \t    !odb_has_object(the_repository->objects, new_oid,\n-\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n+\t\t\t    ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR)) {\n \t\terror(\"unpack should have generated %s, \"\n \t\t      \"but I can't find it!\", oid_to_hex(new_oid));\n \t\tret = \"bad pack\";\ndiff --git a/builtin/remote.c b/builtin/remote.c\nindex 0fddaa1773..de989ea3ba 100644\n--- a/builtin/remote.c\n+++ b/builtin/remote.c\n@@ -473,7 +473,7 @@ static int get_push_ref_states(const struct ref *remote_refs,\n \t\telse if (is_null_oid(&ref->old_oid))\n \t\t\tinfo->status = PUSH_STATUS_CREATE;\n \t\telse if (odb_has_object(the_repository->objects, &ref->old_oid,\n-\t\t\t\t\tHAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) &&\n+\t\t\t\t\tODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR) &&\n \t\t\t ref_newer(&ref->new_oid, &ref->old_oid))\n \t\t\tinfo->status = PUSH_STATUS_FASTFORWARD;\n \t\telse\ndiff --git a/builtin/show-ref.c b/builtin/show-ref.c\nindex 5d31acea7c..d508441632 100644\n--- a/builtin/show-ref.c\n+++ b/builtin/show-ref.c\n@@ -37,7 +37,7 @@ static void show_one(const struct show_one_options *opts,\n \tstruct object_id peeled;\n \n \tif (!odb_has_object(the_repository->objects, ref->oid,\n-\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\t\t\t    ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR))\n \t\tdie(\"git show-ref: bad ref %s (%s)\", ref->name,\n \t\t    oid_to_hex(ref->oid));\n \ndiff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c\nindex 6fc64e9e4b..871fc8fff5 100644\n--- a/builtin/unpack-objects.c\n+++ b/builtin/unpack-objects.c\n@@ -449,7 +449,7 @@ static void unpack_delta_entry(enum object_type type, unsigned long delta_size,\n \t\tif (!delta_data)\n \t\t\treturn;\n \t\tif (odb_has_object(the_repository->objects, &base_oid,\n-\t\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\t\t\t\t   ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR))\n \t\t\t; /* Ok we have this one */\n \t\telse if (resolve_against_held(nr, &base_oid,\n \t\t\t\t\t      delta_data, delta_size))\ndiff --git a/cache-tree.c b/cache-tree.c\nindex 60059edfb0..fe41068c34 100644\n--- a/cache-tree.c\n+++ b/cache-tree.c\n@@ -239,7 +239,7 @@ int cache_tree_fully_valid(struct cache_tree *it)\n \t\treturn 0;\n \tif (it->entry_count < 0 ||\n \t    odb_has_object(the_repository->objects, &it->oid,\n-\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\t\t\t   ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR))\n \t\treturn 0;\n \tfor (i = 0; i < it->subtree_nr; i++) {\n \t\tif (!cache_tree_fully_valid(it->down[i]->cache_tree))\n@@ -292,7 +292,7 @@ static int update_one(struct cache_tree *it,\n \n \tif (0 <= it->entry_count &&\n \t    odb_has_object(the_repository->objects, &it->oid,\n-\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\t\t\t   ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR))\n \t\treturn it->entry_count;\n \n \t/*\n@@ -400,7 +400,7 @@ static int update_one(struct cache_tree *it,\n \t\tif (is_null_oid(oid) ||\n \t\t    (!ce_missing_ok &&\n \t\t     !odb_has_object(the_repository->objects, oid,\n-\t\t\t\t     HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))) {\n+\t\t\t\t     ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR))) {\n \t\t\tstrbuf_release(&buffer);\n \t\t\tif (expected_missing)\n \t\t\t\treturn -1;\n@@ -448,7 +448,7 @@ static int update_one(struct cache_tree *it,\n \t\tstruct object_id oid;\n \t\thash_object_file(the_hash_algo, buffer.buf, buffer.len,\n \t\t\t\t OBJ_TREE, &oid);\n-\t\tif (odb_has_object(the_repository->objects, &oid, HAS_OBJECT_RECHECK_PACKED))\n+\t\tif (odb_has_object(the_repository->objects, &oid, ODB_HAS_OBJECT_RECHECK_PACKED))\n \t\t\toidcpy(&it->oid, &oid);\n \t\telse\n \t\t\tto_invalidate = 1;\ndiff --git a/fetch-pack.c b/fetch-pack.c\nindex 6ecd468ef7..0f24722a70 100644\n--- a/fetch-pack.c\n+++ b/fetch-pack.c\n@@ -145,7 +145,7 @@ static struct commit *deref_without_lazy_fetch(const struct object_id *oid,\n \tif (commit) {\n \t\tif (mark_tags_complete_and_check_obj_db) {\n \t\t\tif (!odb_has_object(the_repository->objects, oid,\n-\t\t\t\t\t    HAS_OBJECT_RECHECK_PACKED))\n+\t\t\t\t\t    ODB_HAS_OBJECT_RECHECK_PACKED))\n \t\t\t\tdie_in_commit_graph_only(oid);\n \t\t}\n \t\treturn commit;\n@@ -2013,7 +2013,7 @@ static void update_shallow(struct fetch_pack_args *args,\n \t\tstruct object_id *oid = si->shallow->oid;\n \t\tfor (i = 0; i < si->shallow->nr; i++)\n \t\t\tif (odb_has_object(the_repository->objects, &oid[i],\n-\t\t\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\t\t\t\t\t   ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR))\n \t\t\t\toid_array_append(&extra, &oid[i]);\n \t\tif (extra.nr) {\n \t\t\tsetup_alternate_shallow(&shallow_lock,\ndiff --git a/http-push.c b/http-push.c\nindex 9ae6062198..06c3acbb5d 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -1449,7 +1449,7 @@ static void one_remote_ref(const char *refname)\n \t */\n \tif (repo->can_update_info_refs &&\n \t    !odb_has_object(the_repository->objects, &ref->old_oid,\n-\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n+\t\t\t    ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR)) {\n \t\tobj = lookup_unknown_object(the_repository, &ref->old_oid);\n \t\tfprintf(stderr,\t\"  fetch %s for %s\\n\",\n \t\t\toid_to_hex(&ref->old_oid), refname);\n@@ -1655,7 +1655,7 @@ static int delete_remote_branch(const char *pattern, int force)\n \t\tif (is_null_oid(&head_oid))\n \t\t\treturn error(\"Unable to resolve remote HEAD\");\n \t\tif (!odb_has_object(the_repository->objects, &head_oid,\n-\t\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\t\t\t\t    ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR))\n \t\t\treturn error(\"Remote HEAD resolves to object %s\\nwhich does not exist locally, perhaps you need to fetch?\", oid_to_hex(&head_oid));\n \n \t\t/* Remote branch must resolve to a known object */\n@@ -1663,7 +1663,7 @@ static int delete_remote_branch(const char *pattern, int force)\n \t\t\treturn error(\"Unable to resolve remote branch %s\",\n \t\t\t\t     remote_ref->name);\n \t\tif (!odb_has_object(the_repository->objects, &remote_ref->old_oid,\n-\t\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\t\t\t\t    ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR))\n \t\t\treturn error(\"Remote branch %s resolves to object %s\\nwhich does not exist locally, perhaps you need to fetch?\", remote_ref->name, oid_to_hex(&remote_ref->old_oid));\n \n \t\t/* Remote branch must be an ancestor of remote HEAD */\n@@ -1886,7 +1886,7 @@ int cmd_main(int argc, const char **argv)\n \t\t    !is_null_oid(&ref->old_oid) &&\n \t\t    !ref->force) {\n \t\t\tif (!odb_has_object(the_repository->objects, &ref->old_oid,\n-\t\t\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) ||\n+\t\t\t\t\t    ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR) ||\n \t\t\t    !ref_newer(&ref->peer_ref->new_oid,\n \t\t\t\t       &ref->old_oid)) {\n \t\t\t\t/*\ndiff --git a/http-walker.c b/http-walker.c\nindex e886e64866..1b6d496548 100644\n--- a/http-walker.c\n+++ b/http-walker.c\n@@ -139,7 +139,7 @@ static int fill_active_slot(void *data UNUSED)\n \t\tobj_req = list_entry(pos, struct object_request, node);\n \t\tif (obj_req->state == WAITING) {\n \t\t\tif (odb_has_object(the_repository->objects, &obj_req->oid,\n-\t\t\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\t\t\t\t\t   ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR))\n \t\t\t\tobj_req->state = COMPLETE;\n \t\t\telse {\n \t\t\t\tstart_object_request(obj_req);\n@@ -495,7 +495,7 @@ static int fetch_object(struct walker *walker, const struct object_id *oid)\n \t\treturn error(\"Couldn't find request for %s in the queue\", hex);\n \n \tif (odb_has_object(the_repository->objects, &obj_req->oid,\n-\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n+\t\t\t   ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR)) {\n \t\tif (obj_req->req)\n \t\t\tabort_http_object_request(&obj_req->req);\n \t\tabort_object_request(obj_req);\ndiff --git a/list-objects.c b/list-objects.c\nindex 91b23e22f7..724d723c48 100644\n--- a/list-objects.c\n+++ b/list-objects.c\n@@ -75,7 +75,7 @@ static void process_blob(struct traversal_context *ctx,\n \t */\n \tif (ctx->revs->exclude_promisor_objects &&\n \t    !odb_has_object(the_repository->objects, &obj->oid,\n-\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) &&\n+\t\t\t    ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR) &&\n \t    is_promisor_object(ctx->revs->repo, &obj->oid))\n \t\treturn;\n \ndiff --git a/notes.c b/notes.c\nindex 51a7ef9f83..8f315e2a00 100644\n--- a/notes.c\n+++ b/notes.c\n@@ -796,7 +796,7 @@ static int prune_notes_helper(const struct object_id *object_oid,\n \tstruct note_delete_list *n;\n \n \tif (odb_has_object(the_repository->objects, object_oid,\n-\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\t\t\t   ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR))\n \t\treturn 0; /* nothing to do for this note */\n \n \t/* failed to find object => prune this note */\ndiff --git a/object-file.c b/object-file.c\nindex 2146104de8..98a4678ca4 100644\n--- a/object-file.c\n+++ b/object-file.c\n@@ -1378,7 +1378,7 @@ static int already_written(struct odb_transaction_files *transaction,\n {\n \t/* The object may already exist in the repository */\n \tif (odb_has_object(transaction->base.source->odb, oid,\n-\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\t\t\t   ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR))\n \t\treturn 1;\n \n \t/* Might want to keep the list sorted */\ndiff --git a/odb.c b/odb.c\nindex 8220661356..9b28fe25ef 100644\n--- a/odb.c\n+++ b/odb.c\n@@ -872,15 +872,15 @@ void *odb_read_object_peeled(struct object_database *odb,\n }\n \n int odb_has_object(struct object_database *odb, const struct object_id *oid,\n-\t\t   enum has_object_flags flags)\n+\t\t   enum odb_has_object_flags flags)\n {\n \tunsigned object_info_flags = 0;\n \n \tif (!startup_info->have_repository)\n \t\treturn 0;\n-\tif (!(flags & HAS_OBJECT_RECHECK_PACKED))\n+\tif (!(flags & ODB_HAS_OBJECT_RECHECK_PACKED))\n \t\tobject_info_flags |= OBJECT_INFO_QUICK;\n-\tif (!(flags & HAS_OBJECT_FETCH_PROMISOR))\n+\tif (!(flags & ODB_HAS_OBJECT_FETCH_PROMISOR))\n \t\tobject_info_flags |= OBJECT_INFO_SKIP_FETCH_OBJECT;\n \n \treturn odb_read_object_info_extended(odb, oid, NULL, object_info_flags) >= 0;\ndiff --git a/odb.h b/odb.h\nindex 9aadc1177a..8d739e118b 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -395,11 +395,11 @@ int odb_read_object_info(struct object_database *odb,\n \t\t\t const struct object_id *oid,\n \t\t\t unsigned long *sizep);\n \n-enum has_object_flags {\n+enum odb_has_object_flags {\n \t/* Retry packed storage after checking packed and loose storage */\n-\tHAS_OBJECT_RECHECK_PACKED = (1 << 0),\n+\tODB_HAS_OBJECT_RECHECK_PACKED = (1 << 0),\n \t/* Allow fetching the object in case the repository has a promisor remote. */\n-\tHAS_OBJECT_FETCH_PROMISOR = (1 << 1),\n+\tODB_HAS_OBJECT_FETCH_PROMISOR = (1 << 1),\n };\n \n /*\n@@ -408,7 +408,7 @@ enum has_object_flags {\n  */\n int odb_has_object(struct object_database *odb,\n \t\t   const struct object_id *oid,\n-\t\t   enum has_object_flags flags);\n+\t\t   enum odb_has_object_flags flags);\n \n int odb_freshen_object(struct object_database *odb,\n \t\t       const struct object_id *oid);\ndiff --git a/reflog.c b/reflog.c\nindex 1460ae9d0d..82337078d0 100644\n--- a/reflog.c\n+++ b/reflog.c\n@@ -168,7 +168,7 @@ static int tree_is_complete(const struct object_id *oid)\n \tcomplete = 1;\n \twhile (tree_entry(&desc, &entry)) {\n \t\tif (!odb_has_object(the_repository->objects, &entry.oid,\n-\t\t\t\tHAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) ||\n+\t\t\t\tODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR) ||\n \t\t    (S_ISDIR(entry.mode) && !tree_is_complete(&entry.oid))) {\n \t\t\ttree->object.flags |= INCOMPLETE;\n \t\t\tcomplete = 0;\ndiff --git a/refs.c b/refs.c\nindex 685a0c247b..97cdea1f76 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -425,7 +425,7 @@ int ref_resolves_to_object(const char *refname,\n \tif (flags & REF_ISBROKEN)\n \t\treturn 0;\n \tif (!odb_has_object(repo->objects, oid,\n-\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n+\t\t\t    ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR)) {\n \t\terror(_(\"%s does not point to a valid object!\"), refname);\n \t\treturn 0;\n \t}\ndiff --git a/remote.c b/remote.c\nindex 7ca2a6501b..a664cd166a 100644\n--- a/remote.c\n+++ b/remote.c\n@@ -1723,7 +1723,7 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,\n \t\tif (!reject_reason && !ref->deletion && !is_null_oid(&ref->old_oid)) {\n \t\t\tif (starts_with(ref->name, \"refs/tags/\"))\n \t\t\t\treject_reason = REF_STATUS_REJECT_ALREADY_EXISTS;\n-\t\t\telse if (!odb_has_object(the_repository->objects, &ref->old_oid, HAS_OBJECT_RECHECK_PACKED))\n+\t\t\telse if (!odb_has_object(the_repository->objects, &ref->old_oid, ODB_HAS_OBJECT_RECHECK_PACKED))\n \t\t\t\treject_reason = REF_STATUS_REJECT_FETCH_FIRST;\n \t\t\telse if (!lookup_commit_reference_gently(the_repository, &ref->old_oid, 1) ||\n \t\t\t\t !lookup_commit_reference_gently(the_repository, &ref->new_oid, 1))\ndiff --git a/shallow.c b/shallow.c\nindex 7a3dd56795..a8ad92e303 100644\n--- a/shallow.c\n+++ b/shallow.c\n@@ -360,7 +360,7 @@ static int write_one_shallow(const struct commit_graft *graft, void *cb_data)\n \t\treturn 0;\n \tif (data->flags & QUICK) {\n \t\tif (!odb_has_object(the_repository->objects, &graft->oid,\n-\t\t\t\t    HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\t\t\t\t    ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR))\n \t\t\treturn 0;\n \t} else if (data->flags & SEEN_ONLY) {\n \t\tstruct commit *c = lookup_commit(the_repository, &graft->oid);\n@@ -528,7 +528,7 @@ void prepare_shallow_info(struct shallow_info *info, struct oid_array *sa)\n \tALLOC_ARRAY(info->theirs, sa->nr);\n \tfor (size_t i = 0; i < sa->nr; i++) {\n \t\tif (odb_has_object(the_repository->objects, sa->oid + i,\n-\t\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n+\t\t\t\t   ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR)) {\n \t\t\tstruct commit_graft *graft;\n \t\t\tgraft = lookup_commit_graft(the_repository,\n \t\t\t\t\t\t    &sa->oid[i]);\n@@ -567,7 +567,7 @@ void remove_nonexistent_theirs_shallow(struct shallow_info *info)\n \t\tif (i != dst)\n \t\t\tinfo->theirs[dst] = info->theirs[i];\n \t\tif (odb_has_object(the_repository->objects, oid + info->theirs[i],\n-\t\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))\n+\t\t\t\t   ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR))\n \t\t\tdst++;\n \t}\n \tinfo->nr_theirs = dst;\ndiff --git a/walker.c b/walker.c\nindex 91332539d3..e98eb6da53 100644\n--- a/walker.c\n+++ b/walker.c\n@@ -155,7 +155,7 @@ static int process(struct walker *walker, struct object *obj)\n \tobj->flags |= SEEN;\n \n \tif (odb_has_object(the_repository->objects, &obj->oid,\n-\t\t\t   HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {\n+\t\t\t   ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR)) {\n \t\t/* We already have it, so we should scan it now. */\n \t\tobj->flags |= TO_SCAN;\n \t}\n\n-- \n2.53.0.1185.g05d4b7b318.dirty\n\n"},{"id":"540606","messageId":"20260401-pks-odb-cleanups-v1-6-89adba9ada68@pks.im","threadId":"65401","inReplyTo":"20260401-pks-odb-cleanups-v1-0-89adba9ada68@pks.im","subject":"[PATCH 6/6] odb: drop unneeded headers and forward decls","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-03-31T23:57:51Z","receivedAt":"2026-03-31T23:58:10Z","isPatch":true,"body":"There's a couple of unneeded forward declarations and headers in\n\"odb.h\". Drop these.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n odb.h | 12 +++---------\n 1 file changed, 3 insertions(+), 9 deletions(-)\n\ndiff --git a/odb.h b/odb.h\nindex 8d739e118b..3a711f6547 100644\n--- a/odb.h\n+++ b/odb.h\n@@ -1,19 +1,17 @@\n #ifndef ODB_H\n #define ODB_H\n \n-#include \"hashmap.h\"\n #include \"object.h\"\n #include \"oidset.h\"\n #include \"oidmap.h\"\n #include \"string-list.h\"\n #include \"thread-utils.h\"\n \n-struct oidmap;\n-struct oidtree;\n+struct cached_object_entry;\n+struct packed_git;\n+struct repository;\n struct strbuf;\n struct strvec;\n-struct repository;\n-struct multi_pack_index;\n \n /*\n  * Set this to 0 to prevent odb_read_object_info_extended() from fetching missing\n@@ -31,10 +29,6 @@ extern int fetch_if_missing;\n  */\n char *compute_alternate_path(const char *path, struct strbuf *err);\n \n-struct packed_git;\n-struct packfile_store;\n-struct cached_object_entry;\n-\n /*\n  * A transaction may be started for an object database prior to writing new\n  * objects via odb_transaction_begin(). These objects are not committed until\n\n-- \n2.53.0.1185.g05d4b7b318.dirty\n\n"}]}