odb: use enum for `odb_write_object` flags

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>

Patrick Steinhardt committed Apr 1, 2026 at 01:57 UTC b2d421ece6a8e095394e76930e6929ee036571ef
6 files changed +10 -8
object-file.c
+2 -1
@@ -1169,7 +1169,8 @@ cleanup:
1169 int odb_source_loose_write_object(struct odb_source *source,
1170 const void *buf, unsigned long len,
1171 enum object_type type, struct object_id *oid,
1172 - struct object_id *compat_oid_in, unsigned flags)
1172 + struct object_id *compat_oid_in,
1173 + enum odb_write_object_flags flags)
1174 {
1175 const struct git_hash_algo *algo = source->odb->repo->hash_algo;
1176 const struct git_hash_algo *compat = source->odb->repo->compat_hash_algo;
object-file.h
+2 -1
@@ -68,7 +68,8 @@ int odb_source_loose_freshen_object(struct odb_source *source,
68 int odb_source_loose_write_object(struct odb_source *source,
69 const void *buf, unsigned long len,
70 enum object_type type, struct object_id *oid,
71 - struct object_id *compat_oid_in, unsigned flags);
71 + struct object_id *compat_oid_in,
72 + enum odb_write_object_flags flags);
73
74 int odb_source_loose_write_stream(struct odb_source *source,
75 struct odb_write_stream *stream, size_t len,
odb.c
+1 -1
@@ -1053,7 +1053,7 @@ int odb_write_object_ext(struct object_database *odb,
1053 enum object_type type,
1054 struct object_id *oid,
1055 struct object_id *compat_oid,
1056 - unsigned flags)
1056 + enum odb_write_object_flags flags)
1057 {
1058 return odb_source_write_object(odb->sources, buf, len, type,
1059 oid, compat_oid, flags);
odb.h
+2 -2
@@ -561,7 +561,7 @@ int odb_find_abbrev_len(struct object_database *odb,
561 int min_len,
562 unsigned *out);
563
564 -enum {
564 +enum odb_write_object_flags {
565 /*
566 * By default, `odb_write_object()` does not actually write anything
567 * 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,
589 enum object_type type,
590 struct object_id *oid,
591 struct object_id *compat_oid,
592 - unsigned flags);
592 + enum odb_write_object_flags flags);
593
594 static inline int odb_write_object(struct object_database *odb,
595 const void *buf, unsigned long len,
odb/source-files.c
+1 -1
@@ -161,7 +161,7 @@ static int odb_source_files_write_object(struct odb_source *source,
161 enum object_type type,
162 struct object_id *oid,
163 struct object_id *compat_oid,
164 - unsigned flags)
164 + enum odb_write_object_flags flags)
165 {
166 return odb_source_loose_write_object(source, buf, len, type,
167 oid, compat_oid, flags);
odb/source.h
+2 -2
@@ -197,7 +197,7 @@ struct odb_source {
197 enum object_type type,
198 struct object_id *oid,
199 struct object_id *compat_oid,
200 - unsigned flags);
200 + enum odb_write_object_flags flags);
201
202 /*
203 * 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,
405 enum object_type type,
406 struct object_id *oid,
407 struct object_id *compat_oid,
408 - unsigned flags)
408 + enum odb_write_object_flags flags)
409 {
410 return source->write_object(source, buf, len, type, oid,
411 compat_oid, flags);