aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2026-04-08 10:19:17 -0700
committerJunio C Hamano <gitster@pobox.com>2026-04-08 10:19:17 -0700
commit9797fed6cea706f65de64396222545d545226e15 (patch)
tree04ffa4091726ad86bf0d764a75487395e5859cf4
parent2e3028a58c1f1fbf08538443fc30a48ac4f6bacf (diff)
parent109bcb7d1d2f0d2f0514beec15779190c0b89575 (diff)
downloadgit-9797fed6cea706f65de64396222545d545226e15.tar.xz
Merge branch 'ps/odb-cleanup'
Various code clean-up around odb subsystem. * ps/odb-cleanup: odb: drop unneeded headers and forward decls odb: rename `odb_has_object()` flags odb: use enum for `odb_write_object` flags odb: rename `odb_write_object()` flags treewide: use enum for `odb_for_each_object()` flags CodingGuidelines: document our style for flags
-rw-r--r--Documentation/CodingGuidelines12
-rw-r--r--builtin/cat-file.c2
-rw-r--r--builtin/fetch.c4
-rw-r--r--builtin/fsck.c2
-rw-r--r--builtin/index-pack.c2
-rw-r--r--builtin/receive-pack.c2
-rw-r--r--builtin/remote.c2
-rw-r--r--builtin/show-ref.c2
-rw-r--r--builtin/unpack-objects.c2
-rw-r--r--cache-tree.c10
-rw-r--r--fetch-pack.c4
-rw-r--r--http-push.c8
-rw-r--r--http-walker.c4
-rw-r--r--list-objects.c2
-rw-r--r--notes.c2
-rw-r--r--object-file.c9
-rw-r--r--object-file.h3
-rw-r--r--odb.c10
-rw-r--r--odb.h30
-rw-r--r--odb/source-files.c2
-rw-r--r--odb/source.h4
-rw-r--r--packfile.c2
-rw-r--r--packfile.h2
-rw-r--r--reflog.c2
-rw-r--r--refs.c2
-rw-r--r--remote.c2
-rw-r--r--shallow.c6
-rw-r--r--walker.c2
28 files changed, 72 insertions, 64 deletions
diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines
index b8670751f5..4992e52093 100644
--- a/Documentation/CodingGuidelines
+++ b/Documentation/CodingGuidelines
@@ -668,6 +668,18 @@ For C programs:
unsigned other_field:1;
unsigned field_with_longer_name:1;
+ - When a function `F` accepts flags, those flags should be defined as `enum
+ F_flags`. Individual flag definitions should start with `F` and be in
+ all-uppercase letters. Flag values should be represented via bit shifts.
+ E.g.
+
+ enum frobnicate_flags {
+ FROBNICATE_FOO = (1 << 0),
+ FROBNICATE_BAR = (1 << 1),
+ };
+
+ int frobnicate(enum frobnicate_flags flags);
+
- Array names should be named in the singular form if the individual items are
subject of use. E.g.:
diff --git a/builtin/cat-file.c b/builtin/cat-file.c
index cd13a3a89f..d9fbad5358 100644
--- a/builtin/cat-file.c
+++ b/builtin/cat-file.c
@@ -161,7 +161,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
case 'e':
ret = !odb_has_object(the_repository->objects, &oid,
- HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR);
+ ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR);
goto cleanup;
case 'w':
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 4795b2a13c..a22c319467 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -946,7 +946,7 @@ static int update_local_ref(struct ref *ref,
int fast_forward = 0;
if (!odb_has_object(the_repository->objects, &ref->new_oid,
- HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
+ ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR))
die(_("object %s not found"), oid_to_hex(&ref->new_oid));
if (oideq(&ref->old_oid, &ref->new_oid)) {
@@ -1396,7 +1396,7 @@ static int check_exist_and_connected(struct ref *ref_map)
*/
for (r = rm; r; r = r->next) {
if (!odb_has_object(the_repository->objects, &r->old_oid,
- HAS_OBJECT_RECHECK_PACKED))
+ ODB_HAS_OBJECT_RECHECK_PACKED))
return -1;
}
diff --git a/builtin/fsck.c b/builtin/fsck.c
index 99696604b8..248f8ff5a0 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -162,7 +162,7 @@ static int mark_object(struct object *obj, enum object_type type,
if (!(obj->flags & HAS_OBJ)) {
if (parent && !odb_has_object(options->repo->objects, &obj->oid,
- HAS_OBJECT_RECHECK_PACKED)) {
+ ODB_HAS_OBJECT_RECHECK_PACKED)) {
printf_ln(_("broken link from %7s %s\n"
" to %7s %s"),
printable_type(options->repo, &parent->oid, parent->type),
diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index e4129bd605..ca7784dc2c 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -891,7 +891,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
if (startup_info->have_repository) {
read_lock();
collision_test_needed = odb_has_object(the_repository->objects, oid,
- HAS_OBJECT_FETCH_PROMISOR);
+ ODB_HAS_OBJECT_FETCH_PROMISOR);
read_unlock();
}
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index 49090c4d4c..dada55884a 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -1541,7 +1541,7 @@ static const char *update(struct command *cmd, struct shallow_info *si)
if (!is_null_oid(new_oid) &&
!odb_has_object(the_repository->objects, new_oid,
- HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {
+ ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR)) {
error("unpack should have generated %s, "
"but I can't find it!", oid_to_hex(new_oid));
ret = "bad pack";
diff --git a/builtin/remote.c b/builtin/remote.c
index 0fddaa1773..de989ea3ba 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -473,7 +473,7 @@ static int get_push_ref_states(const struct ref *remote_refs,
else if (is_null_oid(&ref->old_oid))
info->status = PUSH_STATUS_CREATE;
else if (odb_has_object(the_repository->objects, &ref->old_oid,
- HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) &&
+ ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR) &&
ref_newer(&ref->new_oid, &ref->old_oid))
info->status = PUSH_STATUS_FASTFORWARD;
else
diff --git a/builtin/show-ref.c b/builtin/show-ref.c
index 5d31acea7c..d508441632 100644
--- a/builtin/show-ref.c
+++ b/builtin/show-ref.c
@@ -37,7 +37,7 @@ static void show_one(const struct show_one_options *opts,
struct object_id peeled;
if (!odb_has_object(the_repository->objects, ref->oid,
- HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
+ ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR))
die("git show-ref: bad ref %s (%s)", ref->name,
oid_to_hex(ref->oid));
diff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c
index d863912b24..e01cf6e360 100644
--- a/builtin/unpack-objects.c
+++ b/builtin/unpack-objects.c
@@ -449,7 +449,7 @@ static void unpack_delta_entry(enum object_type type, unsigned long delta_size,
if (!delta_data)
return;
if (odb_has_object(the_repository->objects, &base_oid,
- HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
+ ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR))
; /* Ok we have this one */
else if (resolve_against_held(nr, &base_oid,
delta_data, delta_size))
diff --git a/cache-tree.c b/cache-tree.c
index 60bcc07c3b..fe41068c34 100644
--- a/cache-tree.c
+++ b/cache-tree.c
@@ -239,7 +239,7 @@ int cache_tree_fully_valid(struct cache_tree *it)
return 0;
if (it->entry_count < 0 ||
odb_has_object(the_repository->objects, &it->oid,
- HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
+ ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR))
return 0;
for (i = 0; i < it->subtree_nr; i++) {
if (!cache_tree_fully_valid(it->down[i]->cache_tree))
@@ -292,7 +292,7 @@ static int update_one(struct cache_tree *it,
if (0 <= it->entry_count &&
odb_has_object(the_repository->objects, &it->oid,
- HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
+ ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR))
return it->entry_count;
/*
@@ -400,7 +400,7 @@ static int update_one(struct cache_tree *it,
if (is_null_oid(oid) ||
(!ce_missing_ok &&
!odb_has_object(the_repository->objects, oid,
- HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))) {
+ ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR))) {
strbuf_release(&buffer);
if (expected_missing)
return -1;
@@ -448,7 +448,7 @@ static int update_one(struct cache_tree *it,
struct object_id oid;
hash_object_file(the_hash_algo, buffer.buf, buffer.len,
OBJ_TREE, &oid);
- if (odb_has_object(the_repository->objects, &oid, HAS_OBJECT_RECHECK_PACKED))
+ if (odb_has_object(the_repository->objects, &oid, ODB_HAS_OBJECT_RECHECK_PACKED))
oidcpy(&it->oid, &oid);
else
to_invalidate = 1;
@@ -456,7 +456,7 @@ static int update_one(struct cache_tree *it,
hash_object_file(the_hash_algo, buffer.buf, buffer.len,
OBJ_TREE, &it->oid);
} else if (odb_write_object_ext(the_repository->objects, buffer.buf, buffer.len, OBJ_TREE,
- &it->oid, NULL, flags & WRITE_TREE_SILENT ? WRITE_OBJECT_SILENT : 0)) {
+ &it->oid, NULL, flags & WRITE_TREE_SILENT ? ODB_WRITE_OBJECT_SILENT : 0)) {
strbuf_release(&buffer);
return -1;
}
diff --git a/fetch-pack.c b/fetch-pack.c
index 7b580920a3..c8fa0a609a 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -144,7 +144,7 @@ static struct commit *deref_without_lazy_fetch(const struct object_id *oid,
if (commit) {
if (mark_tags_complete_and_check_obj_db) {
if (!odb_has_object(the_repository->objects, oid,
- HAS_OBJECT_RECHECK_PACKED))
+ ODB_HAS_OBJECT_RECHECK_PACKED))
die_in_commit_graph_only(oid);
}
return commit;
@@ -2016,7 +2016,7 @@ static void update_shallow(struct fetch_pack_args *args,
struct object_id *oid = si->shallow->oid;
for (i = 0; i < si->shallow->nr; i++)
if (odb_has_object(the_repository->objects, &oid[i],
- HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
+ ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR))
oid_array_append(&extra, &oid[i]);
if (extra.nr) {
setup_alternate_shallow(&shallow_lock,
diff --git a/http-push.c b/http-push.c
index 9ae6062198..06c3acbb5d 100644
--- a/http-push.c
+++ b/http-push.c
@@ -1449,7 +1449,7 @@ static void one_remote_ref(const char *refname)
*/
if (repo->can_update_info_refs &&
!odb_has_object(the_repository->objects, &ref->old_oid,
- HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {
+ ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR)) {
obj = lookup_unknown_object(the_repository, &ref->old_oid);
fprintf(stderr, " fetch %s for %s\n",
oid_to_hex(&ref->old_oid), refname);
@@ -1655,7 +1655,7 @@ static int delete_remote_branch(const char *pattern, int force)
if (is_null_oid(&head_oid))
return error("Unable to resolve remote HEAD");
if (!odb_has_object(the_repository->objects, &head_oid,
- HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
+ ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR))
return error("Remote HEAD resolves to object %s\nwhich does not exist locally, perhaps you need to fetch?", oid_to_hex(&head_oid));
/* Remote branch must resolve to a known object */
@@ -1663,7 +1663,7 @@ static int delete_remote_branch(const char *pattern, int force)
return error("Unable to resolve remote branch %s",
remote_ref->name);
if (!odb_has_object(the_repository->objects, &remote_ref->old_oid,
- HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
+ ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR))
return error("Remote branch %s resolves to object %s\nwhich does not exist locally, perhaps you need to fetch?", remote_ref->name, oid_to_hex(&remote_ref->old_oid));
/* Remote branch must be an ancestor of remote HEAD */
@@ -1886,7 +1886,7 @@ int cmd_main(int argc, const char **argv)
!is_null_oid(&ref->old_oid) &&
!ref->force) {
if (!odb_has_object(the_repository->objects, &ref->old_oid,
- HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) ||
+ ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR) ||
!ref_newer(&ref->peer_ref->new_oid,
&ref->old_oid)) {
/*
diff --git a/http-walker.c b/http-walker.c
index e886e64866..1b6d496548 100644
--- a/http-walker.c
+++ b/http-walker.c
@@ -139,7 +139,7 @@ static int fill_active_slot(void *data UNUSED)
obj_req = list_entry(pos, struct object_request, node);
if (obj_req->state == WAITING) {
if (odb_has_object(the_repository->objects, &obj_req->oid,
- HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
+ ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR))
obj_req->state = COMPLETE;
else {
start_object_request(obj_req);
@@ -495,7 +495,7 @@ static int fetch_object(struct walker *walker, const struct object_id *oid)
return error("Couldn't find request for %s in the queue", hex);
if (odb_has_object(the_repository->objects, &obj_req->oid,
- HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {
+ ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR)) {
if (obj_req->req)
abort_http_object_request(&obj_req->req);
abort_object_request(obj_req);
diff --git a/list-objects.c b/list-objects.c
index 91b23e22f7..724d723c48 100644
--- a/list-objects.c
+++ b/list-objects.c
@@ -75,7 +75,7 @@ static void process_blob(struct traversal_context *ctx,
*/
if (ctx->revs->exclude_promisor_objects &&
!odb_has_object(the_repository->objects, &obj->oid,
- HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) &&
+ ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR) &&
is_promisor_object(ctx->revs->repo, &obj->oid))
return;
diff --git a/notes.c b/notes.c
index 51a7ef9f83..8f315e2a00 100644
--- a/notes.c
+++ b/notes.c
@@ -796,7 +796,7 @@ static int prune_notes_helper(const struct object_id *object_oid,
struct note_delete_list *n;
if (odb_has_object(the_repository->objects, object_oid,
- HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
+ ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR))
return 0; /* nothing to do for this note */
/* failed to find object => prune this note */
diff --git a/object-file.c b/object-file.c
index 9e57eb6c27..c353176206 100644
--- a/object-file.c
+++ b/object-file.c
@@ -909,7 +909,7 @@ static int start_loose_object_common(struct odb_source *source,
fd = create_tmpfile(source->odb->repo, tmp_file, filename);
if (fd < 0) {
- if (flags & WRITE_OBJECT_SILENT)
+ if (flags & ODB_WRITE_OBJECT_SILENT)
return -1;
else if (errno == EACCES)
return error(_("insufficient permission for adding "
@@ -1042,7 +1042,7 @@ static int write_loose_object(struct odb_source *source,
utb.actime = mtime;
utb.modtime = mtime;
if (utime(tmp_file.buf, &utb) < 0 &&
- !(flags & WRITE_OBJECT_SILENT))
+ !(flags & ODB_WRITE_OBJECT_SILENT))
warning_errno(_("failed utime() on %s"), tmp_file.buf);
}
@@ -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;
@@ -1378,7 +1379,7 @@ static int already_written(struct odb_transaction_files *transaction,
{
/* The object may already exist in the repository */
if (odb_has_object(transaction->base.source->odb, oid,
- HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
+ ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR))
return 1;
/* Might want to keep the list sorted */
diff --git a/object-file.h b/object-file.h
index 3686f182e4..5241b8dd5c 100644
--- a/object-file.h
+++ b/object-file.h
@@ -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 3f94a53df1..9b28fe25ef 100644
--- a/odb.c
+++ b/odb.c
@@ -872,15 +872,15 @@ void *odb_read_object_peeled(struct object_database *odb,
}
int odb_has_object(struct object_database *odb, const struct object_id *oid,
- enum has_object_flags flags)
+ enum odb_has_object_flags flags)
{
unsigned object_info_flags = 0;
if (!startup_info->have_repository)
return 0;
- if (!(flags & HAS_OBJECT_RECHECK_PACKED))
+ if (!(flags & ODB_HAS_OBJECT_RECHECK_PACKED))
object_info_flags |= OBJECT_INFO_QUICK;
- if (!(flags & HAS_OBJECT_FETCH_PROMISOR))
+ if (!(flags & ODB_HAS_OBJECT_FETCH_PROMISOR))
object_info_flags |= OBJECT_INFO_SKIP_FETCH_OBJECT;
return odb_read_object_info_extended(odb, oid, NULL, object_info_flags) >= 0;
@@ -922,7 +922,7 @@ int odb_for_each_object(struct object_database *odb,
const struct object_info *request,
odb_for_each_object_cb cb,
void *cb_data,
- unsigned flags)
+ enum odb_for_each_object_flags flags)
{
struct odb_for_each_object_options opts = {
.flags = flags,
@@ -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 984bafca9d..3a711f6547 100644
--- a/odb.h
+++ b/odb.h
@@ -1,19 +1,17 @@
#ifndef ODB_H
#define ODB_H
-#include "hashmap.h"
#include "object.h"
#include "oidset.h"
#include "oidmap.h"
#include "string-list.h"
#include "thread-utils.h"
-struct oidmap;
-struct oidtree;
+struct cached_object_entry;
+struct packed_git;
+struct repository;
struct strbuf;
struct strvec;
-struct repository;
-struct multi_pack_index;
/*
* Set this to 0 to prevent odb_read_object_info_extended() from fetching missing
@@ -31,10 +29,6 @@ extern int fetch_if_missing;
*/
char *compute_alternate_path(const char *path, struct strbuf *err);
-struct packed_git;
-struct packfile_store;
-struct cached_object_entry;
-
/*
* A transaction may be started for an object database prior to writing new
* objects via odb_transaction_begin(). These objects are not committed until
@@ -395,11 +389,11 @@ int odb_read_object_info(struct object_database *odb,
const struct object_id *oid,
unsigned long *sizep);
-enum has_object_flags {
+enum odb_has_object_flags {
/* Retry packed storage after checking packed and loose storage */
- HAS_OBJECT_RECHECK_PACKED = (1 << 0),
+ ODB_HAS_OBJECT_RECHECK_PACKED = (1 << 0),
/* Allow fetching the object in case the repository has a promisor remote. */
- HAS_OBJECT_FETCH_PROMISOR = (1 << 1),
+ ODB_HAS_OBJECT_FETCH_PROMISOR = (1 << 1),
};
/*
@@ -408,7 +402,7 @@ enum has_object_flags {
*/
int odb_has_object(struct object_database *odb,
const struct object_id *oid,
- enum has_object_flags flags);
+ enum odb_has_object_flags flags);
int odb_freshen_object(struct object_database *odb,
const struct object_id *oid);
@@ -522,7 +516,7 @@ int odb_for_each_object(struct object_database *odb,
const struct object_info *request,
odb_for_each_object_cb cb,
void *cb_data,
- unsigned flags);
+ enum odb_for_each_object_flags flags);
enum odb_count_objects_flags {
/*
@@ -561,19 +555,19 @@ 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
* changes that so that the object will be written as a loose object
* and persisted.
*/
- WRITE_OBJECT_PERSIST = (1 << 0),
+ ODB_WRITE_OBJECT_PERSIST = (1 << 0),
/*
* Do not print an error in case something goes wrong.
*/
- WRITE_OBJECT_SILENT = (1 << 1),
+ ODB_WRITE_OBJECT_SILENT = (1 << 1),
};
/*
@@ -589,7 +583,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,
diff --git a/odb/source-files.c b/odb/source-files.c
index 76797569de..b5abd20e97 100644
--- a/odb/source-files.c
+++ b/odb/source-files.c
@@ -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);
diff --git a/odb/source.h b/odb/source.h
index a9d7d0b96f..f706e0608a 100644
--- a/odb/source.h
+++ b/odb/source.h
@@ -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);
diff --git a/packfile.c b/packfile.c
index 48c88748b6..b012d648ad 100644
--- a/packfile.c
+++ b/packfile.c
@@ -2300,7 +2300,7 @@ int has_object_kept_pack(struct repository *r, const struct object_id *oid,
int for_each_object_in_pack(struct packed_git *p,
each_packed_object_fn cb, void *data,
- unsigned flags)
+ enum odb_for_each_object_flags flags)
{
uint32_t i;
int r = 0;
diff --git a/packfile.h b/packfile.h
index 6e8802e2ed..9b647da7dd 100644
--- a/packfile.h
+++ b/packfile.h
@@ -354,7 +354,7 @@ typedef int each_packed_object_fn(const struct object_id *oid,
void *data);
int for_each_object_in_pack(struct packed_git *p,
each_packed_object_fn, void *data,
- unsigned flags);
+ enum odb_for_each_object_flags flags);
/*
* Iterate through all packed objects in the given packfile store and invoke
diff --git a/reflog.c b/reflog.c
index 1460ae9d0d..82337078d0 100644
--- a/reflog.c
+++ b/reflog.c
@@ -168,7 +168,7 @@ static int tree_is_complete(const struct object_id *oid)
complete = 1;
while (tree_entry(&desc, &entry)) {
if (!odb_has_object(the_repository->objects, &entry.oid,
- HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) ||
+ ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR) ||
(S_ISDIR(entry.mode) && !tree_is_complete(&entry.oid))) {
tree->object.flags |= INCOMPLETE;
complete = 0;
diff --git a/refs.c b/refs.c
index 5d1d28523d..bfcb9c7ac3 100644
--- a/refs.c
+++ b/refs.c
@@ -425,7 +425,7 @@ int ref_resolves_to_object(const char *refname,
if (flags & REF_ISBROKEN)
return 0;
if (!odb_has_object(repo->objects, oid,
- HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {
+ ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR)) {
error(_("%s does not point to a valid object!"), refname);
return 0;
}
diff --git a/remote.c b/remote.c
index 7ca2a6501b..a664cd166a 100644
--- a/remote.c
+++ b/remote.c
@@ -1723,7 +1723,7 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,
if (!reject_reason && !ref->deletion && !is_null_oid(&ref->old_oid)) {
if (starts_with(ref->name, "refs/tags/"))
reject_reason = REF_STATUS_REJECT_ALREADY_EXISTS;
- else if (!odb_has_object(the_repository->objects, &ref->old_oid, HAS_OBJECT_RECHECK_PACKED))
+ else if (!odb_has_object(the_repository->objects, &ref->old_oid, ODB_HAS_OBJECT_RECHECK_PACKED))
reject_reason = REF_STATUS_REJECT_FETCH_FIRST;
else if (!lookup_commit_reference_gently(the_repository, &ref->old_oid, 1) ||
!lookup_commit_reference_gently(the_repository, &ref->new_oid, 1))
diff --git a/shallow.c b/shallow.c
index 7a3dd56795..a8ad92e303 100644
--- a/shallow.c
+++ b/shallow.c
@@ -360,7 +360,7 @@ static int write_one_shallow(const struct commit_graft *graft, void *cb_data)
return 0;
if (data->flags & QUICK) {
if (!odb_has_object(the_repository->objects, &graft->oid,
- HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
+ ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR))
return 0;
} else if (data->flags & SEEN_ONLY) {
struct commit *c = lookup_commit(the_repository, &graft->oid);
@@ -528,7 +528,7 @@ void prepare_shallow_info(struct shallow_info *info, struct oid_array *sa)
ALLOC_ARRAY(info->theirs, sa->nr);
for (size_t i = 0; i < sa->nr; i++) {
if (odb_has_object(the_repository->objects, sa->oid + i,
- HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {
+ ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR)) {
struct commit_graft *graft;
graft = lookup_commit_graft(the_repository,
&sa->oid[i]);
@@ -567,7 +567,7 @@ void remove_nonexistent_theirs_shallow(struct shallow_info *info)
if (i != dst)
info->theirs[dst] = info->theirs[i];
if (odb_has_object(the_repository->objects, oid + info->theirs[i],
- HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))
+ ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR))
dst++;
}
info->nr_theirs = dst;
diff --git a/walker.c b/walker.c
index 91332539d3..e98eb6da53 100644
--- a/walker.c
+++ b/walker.c
@@ -155,7 +155,7 @@ static int process(struct walker *walker, struct object *obj)
obj->flags |= SEEN;
if (odb_has_object(the_repository->objects, &obj->oid,
- HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) {
+ ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR)) {
/* We already have it, so we should scan it now. */
obj->flags |= TO_SCAN;
}