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>
maint
Patrick Steinhardt 2026-04-01 01:57:49 +02:00 committed by Junio C Hamano
parent ff2e9d85d6
commit b2d421ece6
6 changed files with 10 additions and 8 deletions

View File

@ -1169,7 +1169,8 @@ cleanup:
int odb_source_loose_write_object(struct odb_source *source, int odb_source_loose_write_object(struct odb_source *source,
const void *buf, unsigned long len, const void *buf, unsigned long len,
enum object_type type, struct object_id *oid, 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 *algo = source->odb->repo->hash_algo;
const struct git_hash_algo *compat = source->odb->repo->compat_hash_algo; const struct git_hash_algo *compat = source->odb->repo->compat_hash_algo;

View 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, int odb_source_loose_write_object(struct odb_source *source,
const void *buf, unsigned long len, const void *buf, unsigned long len,
enum object_type type, struct object_id *oid, 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, int odb_source_loose_write_stream(struct odb_source *source,
struct odb_write_stream *stream, size_t len, struct odb_write_stream *stream, size_t len,

2
odb.c
View File

@ -1053,7 +1053,7 @@ int odb_write_object_ext(struct object_database *odb,
enum object_type type, enum object_type type,
struct object_id *oid, struct object_id *oid,
struct object_id *compat_oid, struct object_id *compat_oid,
unsigned flags) enum odb_write_object_flags flags)
{ {
return odb_source_write_object(odb->sources, buf, len, type, return odb_source_write_object(odb->sources, buf, len, type,
oid, compat_oid, flags); oid, compat_oid, flags);

4
odb.h
View File

@ -561,7 +561,7 @@ int odb_find_abbrev_len(struct object_database *odb,
int min_len, int min_len,
unsigned *out); unsigned *out);


enum { enum odb_write_object_flags {
/* /*
* By default, `odb_write_object()` does not actually write anything * By default, `odb_write_object()` does not actually write anything
* into the object store, but only computes the object ID. This flag * 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, enum object_type type,
struct object_id *oid, struct object_id *oid,
struct object_id *compat_oid, struct object_id *compat_oid,
unsigned flags); enum odb_write_object_flags flags);


static inline int odb_write_object(struct object_database *odb, static inline int odb_write_object(struct object_database *odb,
const void *buf, unsigned long len, const void *buf, unsigned long len,

View File

@ -161,7 +161,7 @@ static int odb_source_files_write_object(struct odb_source *source,
enum object_type type, enum object_type type,
struct object_id *oid, struct object_id *oid,
struct object_id *compat_oid, struct object_id *compat_oid,
unsigned flags) enum odb_write_object_flags flags)
{ {
return odb_source_loose_write_object(source, buf, len, type, return odb_source_loose_write_object(source, buf, len, type,
oid, compat_oid, flags); oid, compat_oid, flags);

View File

@ -197,7 +197,7 @@ struct odb_source {
enum object_type type, enum object_type type,
struct object_id *oid, struct object_id *oid,
struct object_id *compat_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 * 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, enum object_type type,
struct object_id *oid, struct object_id *oid,
struct object_id *compat_oid, struct object_id *compat_oid,
unsigned flags) enum odb_write_object_flags flags)
{ {
return source->write_object(source, buf, len, type, oid, return source->write_object(source, buf, len, type, oid,
compat_oid, flags); compat_oid, flags);