Merge branch 'ps/use-the-repository'

A CPP macro USE_THE_REPOSITORY_VARIABLE is introduced to help
transition the codebase to rely less on the availability of the
singleton the_repository instance.

* ps/use-the-repository:
  hex: guard declarations with `USE_THE_REPOSITORY_VARIABLE`
  t/helper: remove dependency on `the_repository` in "proc-receive"
  t/helper: fix segfault in "oid-array" command without repository
  t/helper: use correct object hash in partial-clone helper
  compat/fsmonitor: fix socket path in networked SHA256 repos
  replace-object: use hash algorithm from passed-in repository
  protocol-caps: use hash algorithm from passed-in repository
  oidset: pass hash algorithm when parsing file
  http-fetch: don't crash when parsing packfile without a repo
  hash-ll: merge with "hash.h"
  refs: avoid include cycle with "repository.h"
  global: introduce `USE_THE_REPOSITORY_VARIABLE` macro
  hash: require hash algorithm in `empty_tree_oid_hex()`
  hash: require hash algorithm in `is_empty_{blob,tree}_oid()`
  hash: make `is_null_oid()` independent of `the_repository`
  hash: convert `oidcmp()` and `oideq()` to compare whole hash
  global: ensure that object IDs are always padded
  hash: require hash algorithm in `oidread()` and `oidclr()`
  hash: require hash algorithm in `hasheq()`, `hashcmp()` and `hashclr()`
  hash: drop (mostly) unused `is_empty_{blob,tree}_sha1()` functions
This commit is contained in:
Junio C Hamano
2024-07-02 09:59:00 -07:00
228 changed files with 1032 additions and 645 deletions

View File

@ -330,7 +330,8 @@ static void read_empty(const struct object_id *oid)
{
struct child_process cmd = CHILD_PROCESS_INIT;
strvec_pushl(&cmd.args, "read-tree", "-m", "-u", empty_tree_oid_hex(),
strvec_pushl(&cmd.args, "read-tree", "-m", "-u",
empty_tree_oid_hex(the_repository->hash_algo),
oid_to_hex(oid), NULL);
cmd.git_cmd = 1;
@ -494,7 +495,7 @@ static void merge_name(const char *remote, struct strbuf *msg)
strbuf_branchname(&bname, remote, 0);
remote = bname.buf;
oidclr(&branch_head);
oidclr(&branch_head, the_repository->hash_algo);
remote_head = get_merge_parent(remote);
if (!remote_head)
die(_("'%s' does not point to a commit"), remote);
@ -1692,7 +1693,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
* index and working tree polluted.
*/
if (save_state(&stash))
oidclr(&stash);
oidclr(&stash, the_repository->hash_algo);
for (i = 0; i < use_strategies_nr; i++) {
int ret, cnt;