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 flagsmaint
commit
9797fed6ce
|
|
@ -668,6 +668,18 @@ For C programs:
|
||||||
unsigned other_field:1;
|
unsigned other_field:1;
|
||||||
unsigned field_with_longer_name: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
|
- Array names should be named in the singular form if the individual items are
|
||||||
subject of use. E.g.:
|
subject of use. E.g.:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -161,7 +161,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
|
||||||
|
|
||||||
case 'e':
|
case 'e':
|
||||||
ret = !odb_has_object(the_repository->objects, &oid,
|
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;
|
goto cleanup;
|
||||||
|
|
||||||
case 'w':
|
case 'w':
|
||||||
|
|
|
||||||
|
|
@ -946,7 +946,7 @@ static int update_local_ref(struct ref *ref,
|
||||||
int fast_forward = 0;
|
int fast_forward = 0;
|
||||||
|
|
||||||
if (!odb_has_object(the_repository->objects, &ref->new_oid,
|
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));
|
die(_("object %s not found"), oid_to_hex(&ref->new_oid));
|
||||||
|
|
||||||
if (oideq(&ref->old_oid, &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) {
|
for (r = rm; r; r = r->next) {
|
||||||
if (!odb_has_object(the_repository->objects, &r->old_oid,
|
if (!odb_has_object(the_repository->objects, &r->old_oid,
|
||||||
HAS_OBJECT_RECHECK_PACKED))
|
ODB_HAS_OBJECT_RECHECK_PACKED))
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -162,7 +162,7 @@ static int mark_object(struct object *obj, enum object_type type,
|
||||||
|
|
||||||
if (!(obj->flags & HAS_OBJ)) {
|
if (!(obj->flags & HAS_OBJ)) {
|
||||||
if (parent && !odb_has_object(options->repo->objects, &obj->oid,
|
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"
|
printf_ln(_("broken link from %7s %s\n"
|
||||||
" to %7s %s"),
|
" to %7s %s"),
|
||||||
printable_type(options->repo, &parent->oid, parent->type),
|
printable_type(options->repo, &parent->oid, parent->type),
|
||||||
|
|
|
||||||
|
|
@ -891,7 +891,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
|
||||||
if (startup_info->have_repository) {
|
if (startup_info->have_repository) {
|
||||||
read_lock();
|
read_lock();
|
||||||
collision_test_needed = odb_has_object(the_repository->objects, oid,
|
collision_test_needed = odb_has_object(the_repository->objects, oid,
|
||||||
HAS_OBJECT_FETCH_PROMISOR);
|
ODB_HAS_OBJECT_FETCH_PROMISOR);
|
||||||
read_unlock();
|
read_unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1541,7 +1541,7 @@ static const char *update(struct command *cmd, struct shallow_info *si)
|
||||||
|
|
||||||
if (!is_null_oid(new_oid) &&
|
if (!is_null_oid(new_oid) &&
|
||||||
!odb_has_object(the_repository->objects, 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, "
|
error("unpack should have generated %s, "
|
||||||
"but I can't find it!", oid_to_hex(new_oid));
|
"but I can't find it!", oid_to_hex(new_oid));
|
||||||
ret = "bad pack";
|
ret = "bad pack";
|
||||||
|
|
|
||||||
|
|
@ -473,7 +473,7 @@ static int get_push_ref_states(const struct ref *remote_refs,
|
||||||
else if (is_null_oid(&ref->old_oid))
|
else if (is_null_oid(&ref->old_oid))
|
||||||
info->status = PUSH_STATUS_CREATE;
|
info->status = PUSH_STATUS_CREATE;
|
||||||
else if (odb_has_object(the_repository->objects, &ref->old_oid,
|
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))
|
ref_newer(&ref->new_oid, &ref->old_oid))
|
||||||
info->status = PUSH_STATUS_FASTFORWARD;
|
info->status = PUSH_STATUS_FASTFORWARD;
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ static void show_one(const struct show_one_options *opts,
|
||||||
struct object_id peeled;
|
struct object_id peeled;
|
||||||
|
|
||||||
if (!odb_has_object(the_repository->objects, ref->oid,
|
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,
|
die("git show-ref: bad ref %s (%s)", ref->name,
|
||||||
oid_to_hex(ref->oid));
|
oid_to_hex(ref->oid));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -449,7 +449,7 @@ static void unpack_delta_entry(enum object_type type, unsigned long delta_size,
|
||||||
if (!delta_data)
|
if (!delta_data)
|
||||||
return;
|
return;
|
||||||
if (odb_has_object(the_repository->objects, &base_oid,
|
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 */
|
; /* Ok we have this one */
|
||||||
else if (resolve_against_held(nr, &base_oid,
|
else if (resolve_against_held(nr, &base_oid,
|
||||||
delta_data, delta_size))
|
delta_data, delta_size))
|
||||||
|
|
|
||||||
10
cache-tree.c
10
cache-tree.c
|
|
@ -239,7 +239,7 @@ int cache_tree_fully_valid(struct cache_tree *it)
|
||||||
return 0;
|
return 0;
|
||||||
if (it->entry_count < 0 ||
|
if (it->entry_count < 0 ||
|
||||||
odb_has_object(the_repository->objects, &it->oid,
|
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;
|
return 0;
|
||||||
for (i = 0; i < it->subtree_nr; i++) {
|
for (i = 0; i < it->subtree_nr; i++) {
|
||||||
if (!cache_tree_fully_valid(it->down[i]->cache_tree))
|
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 &&
|
if (0 <= it->entry_count &&
|
||||||
odb_has_object(the_repository->objects, &it->oid,
|
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;
|
return it->entry_count;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -400,7 +400,7 @@ static int update_one(struct cache_tree *it,
|
||||||
if (is_null_oid(oid) ||
|
if (is_null_oid(oid) ||
|
||||||
(!ce_missing_ok &&
|
(!ce_missing_ok &&
|
||||||
!odb_has_object(the_repository->objects, oid,
|
!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);
|
strbuf_release(&buffer);
|
||||||
if (expected_missing)
|
if (expected_missing)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -448,7 +448,7 @@ static int update_one(struct cache_tree *it,
|
||||||
struct object_id oid;
|
struct object_id oid;
|
||||||
hash_object_file(the_hash_algo, buffer.buf, buffer.len,
|
hash_object_file(the_hash_algo, buffer.buf, buffer.len,
|
||||||
OBJ_TREE, &oid);
|
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);
|
oidcpy(&it->oid, &oid);
|
||||||
else
|
else
|
||||||
to_invalidate = 1;
|
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,
|
hash_object_file(the_hash_algo, buffer.buf, buffer.len,
|
||||||
OBJ_TREE, &it->oid);
|
OBJ_TREE, &it->oid);
|
||||||
} else if (odb_write_object_ext(the_repository->objects, buffer.buf, buffer.len, OBJ_TREE,
|
} 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);
|
strbuf_release(&buffer);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -144,7 +144,7 @@ static struct commit *deref_without_lazy_fetch(const struct object_id *oid,
|
||||||
if (commit) {
|
if (commit) {
|
||||||
if (mark_tags_complete_and_check_obj_db) {
|
if (mark_tags_complete_and_check_obj_db) {
|
||||||
if (!odb_has_object(the_repository->objects, oid,
|
if (!odb_has_object(the_repository->objects, oid,
|
||||||
HAS_OBJECT_RECHECK_PACKED))
|
ODB_HAS_OBJECT_RECHECK_PACKED))
|
||||||
die_in_commit_graph_only(oid);
|
die_in_commit_graph_only(oid);
|
||||||
}
|
}
|
||||||
return commit;
|
return commit;
|
||||||
|
|
@ -2016,7 +2016,7 @@ static void update_shallow(struct fetch_pack_args *args,
|
||||||
struct object_id *oid = si->shallow->oid;
|
struct object_id *oid = si->shallow->oid;
|
||||||
for (i = 0; i < si->shallow->nr; i++)
|
for (i = 0; i < si->shallow->nr; i++)
|
||||||
if (odb_has_object(the_repository->objects, &oid[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]);
|
oid_array_append(&extra, &oid[i]);
|
||||||
if (extra.nr) {
|
if (extra.nr) {
|
||||||
setup_alternate_shallow(&shallow_lock,
|
setup_alternate_shallow(&shallow_lock,
|
||||||
|
|
|
||||||
|
|
@ -1449,7 +1449,7 @@ static void one_remote_ref(const char *refname)
|
||||||
*/
|
*/
|
||||||
if (repo->can_update_info_refs &&
|
if (repo->can_update_info_refs &&
|
||||||
!odb_has_object(the_repository->objects, &ref->old_oid,
|
!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);
|
obj = lookup_unknown_object(the_repository, &ref->old_oid);
|
||||||
fprintf(stderr, " fetch %s for %s\n",
|
fprintf(stderr, " fetch %s for %s\n",
|
||||||
oid_to_hex(&ref->old_oid), refname);
|
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))
|
if (is_null_oid(&head_oid))
|
||||||
return error("Unable to resolve remote HEAD");
|
return error("Unable to resolve remote HEAD");
|
||||||
if (!odb_has_object(the_repository->objects, &head_oid,
|
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));
|
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 */
|
/* 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",
|
return error("Unable to resolve remote branch %s",
|
||||||
remote_ref->name);
|
remote_ref->name);
|
||||||
if (!odb_has_object(the_repository->objects, &remote_ref->old_oid,
|
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));
|
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 */
|
/* 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) &&
|
!is_null_oid(&ref->old_oid) &&
|
||||||
!ref->force) {
|
!ref->force) {
|
||||||
if (!odb_has_object(the_repository->objects, &ref->old_oid,
|
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_newer(&ref->peer_ref->new_oid,
|
||||||
&ref->old_oid)) {
|
&ref->old_oid)) {
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -139,7 +139,7 @@ static int fill_active_slot(void *data UNUSED)
|
||||||
obj_req = list_entry(pos, struct object_request, node);
|
obj_req = list_entry(pos, struct object_request, node);
|
||||||
if (obj_req->state == WAITING) {
|
if (obj_req->state == WAITING) {
|
||||||
if (odb_has_object(the_repository->objects, &obj_req->oid,
|
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;
|
obj_req->state = COMPLETE;
|
||||||
else {
|
else {
|
||||||
start_object_request(obj_req);
|
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);
|
return error("Couldn't find request for %s in the queue", hex);
|
||||||
|
|
||||||
if (odb_has_object(the_repository->objects, &obj_req->oid,
|
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)
|
if (obj_req->req)
|
||||||
abort_http_object_request(&obj_req->req);
|
abort_http_object_request(&obj_req->req);
|
||||||
abort_object_request(obj_req);
|
abort_object_request(obj_req);
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ static void process_blob(struct traversal_context *ctx,
|
||||||
*/
|
*/
|
||||||
if (ctx->revs->exclude_promisor_objects &&
|
if (ctx->revs->exclude_promisor_objects &&
|
||||||
!odb_has_object(the_repository->objects, &obj->oid,
|
!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))
|
is_promisor_object(ctx->revs->repo, &obj->oid))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
||||||
2
notes.c
2
notes.c
|
|
@ -796,7 +796,7 @@ static int prune_notes_helper(const struct object_id *object_oid,
|
||||||
struct note_delete_list *n;
|
struct note_delete_list *n;
|
||||||
|
|
||||||
if (odb_has_object(the_repository->objects, object_oid,
|
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 */
|
return 0; /* nothing to do for this note */
|
||||||
|
|
||||||
/* failed to find object => prune this note */
|
/* failed to find object => prune this note */
|
||||||
|
|
|
||||||
|
|
@ -909,7 +909,7 @@ static int start_loose_object_common(struct odb_source *source,
|
||||||
|
|
||||||
fd = create_tmpfile(source->odb->repo, tmp_file, filename);
|
fd = create_tmpfile(source->odb->repo, tmp_file, filename);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
if (flags & WRITE_OBJECT_SILENT)
|
if (flags & ODB_WRITE_OBJECT_SILENT)
|
||||||
return -1;
|
return -1;
|
||||||
else if (errno == EACCES)
|
else if (errno == EACCES)
|
||||||
return error(_("insufficient permission for adding "
|
return error(_("insufficient permission for adding "
|
||||||
|
|
@ -1042,7 +1042,7 @@ static int write_loose_object(struct odb_source *source,
|
||||||
utb.actime = mtime;
|
utb.actime = mtime;
|
||||||
utb.modtime = mtime;
|
utb.modtime = mtime;
|
||||||
if (utime(tmp_file.buf, &utb) < 0 &&
|
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);
|
warning_errno(_("failed utime() on %s"), tmp_file.buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -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;
|
||||||
|
|
@ -1378,7 +1379,7 @@ static int already_written(struct odb_transaction_files *transaction,
|
||||||
{
|
{
|
||||||
/* The object may already exist in the repository */
|
/* The object may already exist in the repository */
|
||||||
if (odb_has_object(transaction->base.source->odb, oid,
|
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;
|
return 1;
|
||||||
|
|
||||||
/* Might want to keep the list sorted */
|
/* Might want to keep the list sorted */
|
||||||
|
|
|
||||||
|
|
@ -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,
|
||||||
|
|
|
||||||
10
odb.c
10
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,
|
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;
|
unsigned object_info_flags = 0;
|
||||||
|
|
||||||
if (!startup_info->have_repository)
|
if (!startup_info->have_repository)
|
||||||
return 0;
|
return 0;
|
||||||
if (!(flags & HAS_OBJECT_RECHECK_PACKED))
|
if (!(flags & ODB_HAS_OBJECT_RECHECK_PACKED))
|
||||||
object_info_flags |= OBJECT_INFO_QUICK;
|
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;
|
object_info_flags |= OBJECT_INFO_SKIP_FETCH_OBJECT;
|
||||||
|
|
||||||
return odb_read_object_info_extended(odb, oid, NULL, object_info_flags) >= 0;
|
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,
|
const struct object_info *request,
|
||||||
odb_for_each_object_cb cb,
|
odb_for_each_object_cb cb,
|
||||||
void *cb_data,
|
void *cb_data,
|
||||||
unsigned flags)
|
enum odb_for_each_object_flags flags)
|
||||||
{
|
{
|
||||||
struct odb_for_each_object_options opts = {
|
struct odb_for_each_object_options opts = {
|
||||||
.flags = flags,
|
.flags = flags,
|
||||||
|
|
@ -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);
|
||||||
|
|
|
||||||
30
odb.h
30
odb.h
|
|
@ -1,19 +1,17 @@
|
||||||
#ifndef ODB_H
|
#ifndef ODB_H
|
||||||
#define ODB_H
|
#define ODB_H
|
||||||
|
|
||||||
#include "hashmap.h"
|
|
||||||
#include "object.h"
|
#include "object.h"
|
||||||
#include "oidset.h"
|
#include "oidset.h"
|
||||||
#include "oidmap.h"
|
#include "oidmap.h"
|
||||||
#include "string-list.h"
|
#include "string-list.h"
|
||||||
#include "thread-utils.h"
|
#include "thread-utils.h"
|
||||||
|
|
||||||
struct oidmap;
|
struct cached_object_entry;
|
||||||
struct oidtree;
|
struct packed_git;
|
||||||
|
struct repository;
|
||||||
struct strbuf;
|
struct strbuf;
|
||||||
struct strvec;
|
struct strvec;
|
||||||
struct repository;
|
|
||||||
struct multi_pack_index;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set this to 0 to prevent odb_read_object_info_extended() from fetching missing
|
* 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);
|
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
|
* A transaction may be started for an object database prior to writing new
|
||||||
* objects via odb_transaction_begin(). These objects are not committed until
|
* 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,
|
const struct object_id *oid,
|
||||||
unsigned long *sizep);
|
unsigned long *sizep);
|
||||||
|
|
||||||
enum has_object_flags {
|
enum odb_has_object_flags {
|
||||||
/* Retry packed storage after checking packed and loose storage */
|
/* 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. */
|
/* 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,
|
int odb_has_object(struct object_database *odb,
|
||||||
const struct object_id *oid,
|
const struct object_id *oid,
|
||||||
enum has_object_flags flags);
|
enum odb_has_object_flags flags);
|
||||||
|
|
||||||
int odb_freshen_object(struct object_database *odb,
|
int odb_freshen_object(struct object_database *odb,
|
||||||
const struct object_id *oid);
|
const struct object_id *oid);
|
||||||
|
|
@ -522,7 +516,7 @@ int odb_for_each_object(struct object_database *odb,
|
||||||
const struct object_info *request,
|
const struct object_info *request,
|
||||||
odb_for_each_object_cb cb,
|
odb_for_each_object_cb cb,
|
||||||
void *cb_data,
|
void *cb_data,
|
||||||
unsigned flags);
|
enum odb_for_each_object_flags flags);
|
||||||
|
|
||||||
enum odb_count_objects_flags {
|
enum odb_count_objects_flags {
|
||||||
/*
|
/*
|
||||||
|
|
@ -561,19 +555,19 @@ 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
|
||||||
* changes that so that the object will be written as a loose object
|
* changes that so that the object will be written as a loose object
|
||||||
* and persisted.
|
* and persisted.
|
||||||
*/
|
*/
|
||||||
WRITE_OBJECT_PERSIST = (1 << 0),
|
ODB_WRITE_OBJECT_PERSIST = (1 << 0),
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Do not print an error in case something goes wrong.
|
* 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,
|
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,
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
|
|
|
||||||
|
|
@ -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,
|
int for_each_object_in_pack(struct packed_git *p,
|
||||||
each_packed_object_fn cb, void *data,
|
each_packed_object_fn cb, void *data,
|
||||||
unsigned flags)
|
enum odb_for_each_object_flags flags)
|
||||||
{
|
{
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
int r = 0;
|
int r = 0;
|
||||||
|
|
|
||||||
|
|
@ -354,7 +354,7 @@ typedef int each_packed_object_fn(const struct object_id *oid,
|
||||||
void *data);
|
void *data);
|
||||||
int for_each_object_in_pack(struct packed_git *p,
|
int for_each_object_in_pack(struct packed_git *p,
|
||||||
each_packed_object_fn, void *data,
|
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
|
* Iterate through all packed objects in the given packfile store and invoke
|
||||||
|
|
|
||||||
2
reflog.c
2
reflog.c
|
|
@ -168,7 +168,7 @@ static int tree_is_complete(const struct object_id *oid)
|
||||||
complete = 1;
|
complete = 1;
|
||||||
while (tree_entry(&desc, &entry)) {
|
while (tree_entry(&desc, &entry)) {
|
||||||
if (!odb_has_object(the_repository->objects, &entry.oid,
|
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))) {
|
(S_ISDIR(entry.mode) && !tree_is_complete(&entry.oid))) {
|
||||||
tree->object.flags |= INCOMPLETE;
|
tree->object.flags |= INCOMPLETE;
|
||||||
complete = 0;
|
complete = 0;
|
||||||
|
|
|
||||||
2
refs.c
2
refs.c
|
|
@ -425,7 +425,7 @@ int ref_resolves_to_object(const char *refname,
|
||||||
if (flags & REF_ISBROKEN)
|
if (flags & REF_ISBROKEN)
|
||||||
return 0;
|
return 0;
|
||||||
if (!odb_has_object(repo->objects, oid,
|
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);
|
error(_("%s does not point to a valid object!"), refname);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
2
remote.c
2
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 (!reject_reason && !ref->deletion && !is_null_oid(&ref->old_oid)) {
|
||||||
if (starts_with(ref->name, "refs/tags/"))
|
if (starts_with(ref->name, "refs/tags/"))
|
||||||
reject_reason = REF_STATUS_REJECT_ALREADY_EXISTS;
|
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;
|
reject_reason = REF_STATUS_REJECT_FETCH_FIRST;
|
||||||
else if (!lookup_commit_reference_gently(the_repository, &ref->old_oid, 1) ||
|
else if (!lookup_commit_reference_gently(the_repository, &ref->old_oid, 1) ||
|
||||||
!lookup_commit_reference_gently(the_repository, &ref->new_oid, 1))
|
!lookup_commit_reference_gently(the_repository, &ref->new_oid, 1))
|
||||||
|
|
|
||||||
|
|
@ -360,7 +360,7 @@ static int write_one_shallow(const struct commit_graft *graft, void *cb_data)
|
||||||
return 0;
|
return 0;
|
||||||
if (data->flags & QUICK) {
|
if (data->flags & QUICK) {
|
||||||
if (!odb_has_object(the_repository->objects, &graft->oid,
|
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;
|
return 0;
|
||||||
} else if (data->flags & SEEN_ONLY) {
|
} else if (data->flags & SEEN_ONLY) {
|
||||||
struct commit *c = lookup_commit(the_repository, &graft->oid);
|
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);
|
ALLOC_ARRAY(info->theirs, sa->nr);
|
||||||
for (size_t i = 0; i < sa->nr; i++) {
|
for (size_t i = 0; i < sa->nr; i++) {
|
||||||
if (odb_has_object(the_repository->objects, sa->oid + 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;
|
struct commit_graft *graft;
|
||||||
graft = lookup_commit_graft(the_repository,
|
graft = lookup_commit_graft(the_repository,
|
||||||
&sa->oid[i]);
|
&sa->oid[i]);
|
||||||
|
|
@ -567,7 +567,7 @@ void remove_nonexistent_theirs_shallow(struct shallow_info *info)
|
||||||
if (i != dst)
|
if (i != dst)
|
||||||
info->theirs[dst] = info->theirs[i];
|
info->theirs[dst] = info->theirs[i];
|
||||||
if (odb_has_object(the_repository->objects, oid + 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++;
|
dst++;
|
||||||
}
|
}
|
||||||
info->nr_theirs = dst;
|
info->nr_theirs = dst;
|
||||||
|
|
|
||||||
2
walker.c
2
walker.c
|
|
@ -155,7 +155,7 @@ static int process(struct walker *walker, struct object *obj)
|
||||||
obj->flags |= SEEN;
|
obj->flags |= SEEN;
|
||||||
|
|
||||||
if (odb_has_object(the_repository->objects, &obj->oid,
|
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. */
|
/* We already have it, so we should scan it now. */
|
||||||
obj->flags |= TO_SCAN;
|
obj->flags |= TO_SCAN;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue