Skip to content

Commit b2d421e

Browse files
pks-tgitster
authored andcommitted
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>
1 parent ff2e9d8 commit b2d421e

6 files changed

Lines changed: 10 additions & 8 deletions

File tree

object-file.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1169,7 +1169,8 @@ int odb_source_loose_write_stream(struct odb_source *source,
11691169
int odb_source_loose_write_object(struct odb_source *source,
11701170
const void *buf, unsigned long len,
11711171
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)
11731174
{
11741175
const struct git_hash_algo *algo = source->odb->repo->hash_algo;
11751176
const struct git_hash_algo *compat = source->odb->repo->compat_hash_algo;

object-file.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ int odb_source_loose_freshen_object(struct odb_source *source,
6868
int odb_source_loose_write_object(struct odb_source *source,
6969
const void *buf, unsigned long len,
7070
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);
7273

7374
int odb_source_loose_write_stream(struct odb_source *source,
7475
struct odb_write_stream *stream, size_t len,

odb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1053,7 +1053,7 @@ int odb_write_object_ext(struct object_database *odb,
10531053
enum object_type type,
10541054
struct object_id *oid,
10551055
struct object_id *compat_oid,
1056-
unsigned flags)
1056+
enum odb_write_object_flags flags)
10571057
{
10581058
return odb_source_write_object(odb->sources, buf, len, type,
10591059
oid, compat_oid, flags);

odb.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ int odb_find_abbrev_len(struct object_database *odb,
561561
int min_len,
562562
unsigned *out);
563563

564-
enum {
564+
enum odb_write_object_flags {
565565
/*
566566
* By default, `odb_write_object()` does not actually write anything
567567
* 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,
589589
enum object_type type,
590590
struct object_id *oid,
591591
struct object_id *compat_oid,
592-
unsigned flags);
592+
enum odb_write_object_flags flags);
593593

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

odb/source-files.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ static int odb_source_files_write_object(struct odb_source *source,
161161
enum object_type type,
162162
struct object_id *oid,
163163
struct object_id *compat_oid,
164-
unsigned flags)
164+
enum odb_write_object_flags flags)
165165
{
166166
return odb_source_loose_write_object(source, buf, len, type,
167167
oid, compat_oid, flags);

odb/source.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ struct odb_source {
197197
enum object_type type,
198198
struct object_id *oid,
199199
struct object_id *compat_oid,
200-
unsigned flags);
200+
enum odb_write_object_flags flags);
201201

202202
/*
203203
* 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,
405405
enum object_type type,
406406
struct object_id *oid,
407407
struct object_id *compat_oid,
408-
unsigned flags)
408+
enum odb_write_object_flags flags)
409409
{
410410
return source->write_object(source, buf, len, type, oid,
411411
compat_oid, flags);

0 commit comments

Comments
 (0)