Merge branch 'ps/object-file-wo-the-repository'

Reduce implicit assumption and dependence on the_repository in the
object-file subsystem.

* ps/object-file-wo-the-repository:
  object-file: get rid of `the_repository` in index-related functions
  object-file: get rid of `the_repository` in `force_object_loose()`
  object-file: get rid of `the_repository` in `read_loose_object()`
  object-file: get rid of `the_repository` in loose object iterators
  object-file: remove declaration for `for_each_file_in_obj_subdir()`
  object-file: inline `for_each_loose_file_in_objdir_buf()`
  object-file: get rid of `the_repository` when writing objects
  odb: introduce `odb_write_object()`
  loose: write loose objects map via their source
  object-file: get rid of `the_repository` in `finalize_object_file()`
  object-file: get rid of `the_repository` in `loose_object_info()`
  object-file: get rid of `the_repository` when freshening objects
  object-file: inline `check_and_freshen()` functions
  object-file: get rid of `the_repository` in `has_loose_object()`
  object-file: stop using `the_hash_algo`
  object-file: fix -Wsign-compare warnings
This commit is contained in:
Junio C Hamano
2025-08-05 11:53:55 -07:00
39 changed files with 332 additions and 293 deletions

12
notes.c
View File

@@ -682,7 +682,8 @@ static int tree_write_stack_finish_subtree(struct tree_write_stack *tws)
ret = tree_write_stack_finish_subtree(n);
if (ret)
return ret;
ret = write_object_file(n->buf.buf, n->buf.len, OBJ_TREE, &s);
ret = odb_write_object(the_repository->objects, n->buf.buf,
n->buf.len, OBJ_TREE, &s);
if (ret)
return ret;
strbuf_release(&n->buf);
@@ -847,7 +848,8 @@ int combine_notes_concatenate(struct object_id *cur_oid,
free(new_msg);
/* create a new blob object from buf */
ret = write_object_file(buf, buf_len, OBJ_BLOB, cur_oid);
ret = odb_write_object(the_repository->objects, buf,
buf_len, OBJ_BLOB, cur_oid);
free(buf);
return ret;
}
@@ -927,7 +929,8 @@ int combine_notes_cat_sort_uniq(struct object_id *cur_oid,
string_list_join_lines_helper, &buf))
goto out;
ret = write_object_file(buf.buf, buf.len, OBJ_BLOB, cur_oid);
ret = odb_write_object(the_repository->objects, buf.buf,
buf.len, OBJ_BLOB, cur_oid);
out:
strbuf_release(&buf);
@@ -1215,7 +1218,8 @@ int write_notes_tree(struct notes_tree *t, struct object_id *result)
ret = for_each_note(t, flags, write_each_note, &cb_data) ||
write_each_non_note_until(NULL, &cb_data) ||
tree_write_stack_finish_subtree(&root) ||
write_object_file(root.buf.buf, root.buf.len, OBJ_TREE, result);
odb_write_object(the_repository->objects, root.buf.buf,
root.buf.len, OBJ_TREE, result);
strbuf_release(&root.buf);
return ret;
}