Skip to content

Commit

Permalink
for_each_*_object: take flag arguments as enum
Browse files Browse the repository at this point in the history
It's not wrong to pass our flags in an "unsigned", as we
know it will be at least as large as the enum.  However,
using the enum in the declaration makes it more obvious
where to find the list of flags.

While we're here, let's also drop the "extern" noise-words
from the declarations, per our modern coding style.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
peff authored and gitster committed Aug 13, 2018
1 parent 202e7f1 commit a7ff6f5
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
3 changes: 2 additions & 1 deletion cache.h
Expand Up @@ -1640,7 +1640,8 @@ enum for_each_object_flags {
* repository and any alternates repositories (unless the
* LOCAL_ONLY flag is set).
*/
extern int for_each_loose_object(each_loose_object_fn, void *, unsigned flags);
int for_each_loose_object(each_loose_object_fn, void *,
enum for_each_object_flags flags);

/*
* Set this to 0 to prevent sha1_object_info_extended() from fetching missing
Expand Down
3 changes: 2 additions & 1 deletion packfile.c
Expand Up @@ -1904,7 +1904,8 @@ int for_each_object_in_pack(struct packed_git *p, each_packed_object_fn cb, void
return r;
}

int for_each_packed_object(each_packed_object_fn cb, void *data, unsigned flags)
int for_each_packed_object(each_packed_object_fn cb, void *data,
enum for_each_object_flags flags)
{
struct packed_git *p;
int r = 0;
Expand Down
5 changes: 3 additions & 2 deletions packfile.h
Expand Up @@ -158,8 +158,9 @@ typedef int each_packed_object_fn(const struct object_id *oid,
struct packed_git *pack,
uint32_t pos,
void *data);
extern int for_each_object_in_pack(struct packed_git *p, each_packed_object_fn, void *data);
extern int for_each_packed_object(each_packed_object_fn, void *, unsigned flags);
int for_each_object_in_pack(struct packed_git *p, each_packed_object_fn, void *data);
int for_each_packed_object(each_packed_object_fn, void *,
enum for_each_object_flags flags);

/*
* Return 1 if an object in a promisor packfile is or refers to the given
Expand Down
3 changes: 2 additions & 1 deletion sha1-file.c
Expand Up @@ -2146,7 +2146,8 @@ static int loose_from_alt_odb(struct alternate_object_database *alt,
return r;
}

int for_each_loose_object(each_loose_object_fn cb, void *data, unsigned flags)
int for_each_loose_object(each_loose_object_fn cb, void *data,
enum for_each_object_flags flags)
{
struct loose_alt_odb_data alt;
int r;
Expand Down

0 comments on commit a7ff6f5

Please sign in to comment.