]> git.ipfire.org Git - thirdparty/git.git/commitdiff
odb: use enum for `odb_write_object` flags
authorPatrick Steinhardt <ps@pks.im>
Tue, 31 Mar 2026 23:57:49 +0000 (01:57 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 1 Apr 2026 03:43:13 +0000 (20:43 -0700)
We've got a couple of functions that accept `odb_write_object()` flags,
but all of them accept the flags as an `unsigned` integer. In fact, we
don't even have an `enum` for the flags field.

Introduce this `enum` and adapt functions accordingly according to our
coding style.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
object-file.c
object-file.h
odb.c
odb.h
odb/source-files.c
odb/source.h

index db1a420ab6d4e6016edc2e81581cc11fb0b393f3..2146104de8cc687d870df2da18ef903aeb244995 100644 (file)
@@ -1169,7 +1169,8 @@ cleanup:
 int odb_source_loose_write_object(struct odb_source *source,
                                  const void *buf, unsigned long len,
                                  enum object_type type, struct object_id *oid,
-                                 struct object_id *compat_oid_in, unsigned flags)
+                                 struct object_id *compat_oid_in,
+                                 enum odb_write_object_flags flags)
 {
        const struct git_hash_algo *algo = source->odb->repo->hash_algo;
        const struct git_hash_algo *compat = source->odb->repo->compat_hash_algo;
index 3686f182e4deb0b357e1a061c701578cef9ab016..5241b8dd5c564da6cbb3deda8af9f4b4386edbfb 100644 (file)
@@ -68,7 +68,8 @@ int odb_source_loose_freshen_object(struct odb_source *source,
 int odb_source_loose_write_object(struct odb_source *source,
                                  const void *buf, unsigned long len,
                                  enum object_type type, struct object_id *oid,
-                                 struct object_id *compat_oid_in, unsigned flags);
+                                 struct object_id *compat_oid_in,
+                                 enum odb_write_object_flags flags);
 
 int odb_source_loose_write_stream(struct odb_source *source,
                                  struct odb_write_stream *stream, size_t len,
diff --git a/odb.c b/odb.c
index 9a11c600487ded2825844f3bcd264aff5c488bdd..8220661356b29bc83536a2d274eb7ae683ea748e 100644 (file)
--- a/odb.c
+++ b/odb.c
@@ -1053,7 +1053,7 @@ int odb_write_object_ext(struct object_database *odb,
                         enum object_type type,
                         struct object_id *oid,
                         struct object_id *compat_oid,
-                        unsigned flags)
+                        enum odb_write_object_flags flags)
 {
        return odb_source_write_object(odb->sources, buf, len, type,
                                       oid, compat_oid, flags);
diff --git a/odb.h b/odb.h
index 083c25609e59e843c688fa714877c70c9f1aec24..9aadc1177a9e606822b4c87b2d40b53441a3a7e8 100644 (file)
--- a/odb.h
+++ b/odb.h
@@ -561,7 +561,7 @@ int odb_find_abbrev_len(struct object_database *odb,
                        int min_len,
                        unsigned *out);
 
-enum {
+enum odb_write_object_flags {
        /*
         * By default, `odb_write_object()` does not actually write anything
         * into the object store, but only computes the object ID. This flag
@@ -589,7 +589,7 @@ int odb_write_object_ext(struct object_database *odb,
                         enum object_type type,
                         struct object_id *oid,
                         struct object_id *compat_oid,
-                        unsigned flags);
+                        enum odb_write_object_flags flags);
 
 static inline int odb_write_object(struct object_database *odb,
                                   const void *buf, unsigned long len,
index 76797569de428001aaec524c33ed2e9d4ccef883..b5abd20e971e78b49f8ae3dfec2130e238bb5b62 100644 (file)
@@ -161,7 +161,7 @@ static int odb_source_files_write_object(struct odb_source *source,
                                         enum object_type type,
                                         struct object_id *oid,
                                         struct object_id *compat_oid,
-                                        unsigned flags)
+                                        enum odb_write_object_flags flags)
 {
        return odb_source_loose_write_object(source, buf, len, type,
                                             oid, compat_oid, flags);
index a9d7d0b96fde72d5257d7f18212417ccac273f4c..f706e0608a48559885e21d1b7aab884bf6db47e7 100644 (file)
@@ -197,7 +197,7 @@ struct odb_source {
                            enum object_type type,
                            struct object_id *oid,
                            struct object_id *compat_oid,
-                           unsigned flags);
+                           enum odb_write_object_flags flags);
 
        /*
         * This callback is expected to persist the given object stream into
@@ -405,7 +405,7 @@ static inline int odb_source_write_object(struct odb_source *source,
                                          enum object_type type,
                                          struct object_id *oid,
                                          struct object_id *compat_oid,
-                                         unsigned flags)
+                                         enum odb_write_object_flags flags)
 {
        return source->write_object(source, buf, len, type, oid,
                                    compat_oid, flags);