]> git.ipfire.org Git - thirdparty/git.git/commitdiff
xdiff-interface: stop using the_repository
authorRené Scharfe <l.s.r@web.de>
Mon, 9 Feb 2026 19:24:52 +0000 (20:24 +0100)
committerJunio C Hamano <gitster@pobox.com>
Tue, 10 Feb 2026 16:16:14 +0000 (08:16 -0800)
Use the algorithm-agnostic is_null_oid() and push the dependency of
read_mmblob() on the_repository->objects to its callers.  This allows it
to be used with arbitrary object databases.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
apply.c
builtin/checkout.c
builtin/merge-file.c
merge-ort.c
notes-merge.c
xdiff-interface.c
xdiff-interface.h

diff --git a/apply.c b/apply.c
index 3de4aa4d2eaac58a439e70a4db32d11cd078eac0..ea90ed16be72f40509f29ee91c0b74c1147859c7 100644 (file)
--- a/apply.c
+++ b/apply.c
@@ -3568,9 +3568,9 @@ static int three_way_merge(struct apply_state *state,
        else if (oideq(base, theirs) || oideq(ours, theirs))
                return resolve_to(image, ours);
 
-       read_mmblob(&base_file, base);
-       read_mmblob(&our_file, ours);
-       read_mmblob(&their_file, theirs);
+       read_mmblob(&base_file, the_repository->objects, base);
+       read_mmblob(&our_file, the_repository->objects, ours);
+       read_mmblob(&their_file, the_repository->objects, theirs);
        merge_opts.variant = state->merge_variant;
        status = ll_merge(&result, path,
                          &base_file, "base",
index 0ba4f03f2ee064d1fd4488e9aefb1e3abaacf2af..f7b313816e77083372dd46479a2161e3c7e63d45 100644 (file)
@@ -294,9 +294,9 @@ static int checkout_merged(int pos, const struct checkout *state,
        if (is_null_oid(&threeway[1]) || is_null_oid(&threeway[2]))
                return error(_("path '%s' does not have necessary versions"), path);
 
-       read_mmblob(&ancestor, &threeway[0]);
-       read_mmblob(&ours, &threeway[1]);
-       read_mmblob(&theirs, &threeway[2]);
+       read_mmblob(&ancestor, the_repository->objects, &threeway[0]);
+       read_mmblob(&ours, the_repository->objects, &threeway[1]);
+       read_mmblob(&theirs, the_repository->objects, &threeway[2]);
 
        repo_config_get_bool(the_repository, "merge.renormalize", &renormalize);
        ll_opts.renormalize = renormalize;
index 46775d0c79f4547a23b9b7e9abdef976a2005832..c5dbd028fd17a19250c3647fd36b04ebb9760274 100644 (file)
@@ -128,7 +128,7 @@ int cmd_merge_file(int argc,
                                ret = error(_("object '%s' does not exist"),
                                              argv[i]);
                        else if (!oideq(&oid, the_hash_algo->empty_blob))
-                               read_mmblob(mmf, &oid);
+                               read_mmblob(mmf, the_repository->objects, &oid);
                        else
                                read_mmfile(mmf, "/dev/null");
                } else if (read_mmfile(mmf, fname)) {
index e80e4f735a60f049c68c653946d0a6d407926afd..a4103d56edc0d802b9e601d3338cbc92f72277b5 100644 (file)
@@ -2136,9 +2136,9 @@ static int merge_3way(struct merge_options *opt,
                name2 = mkpathdup("%s:%s", opt->branch2,  pathnames[2]);
        }
 
-       read_mmblob(&orig, o);
-       read_mmblob(&src1, a);
-       read_mmblob(&src2, b);
+       read_mmblob(&orig, the_repository->objects, o);
+       read_mmblob(&src1, the_repository->objects, a);
+       read_mmblob(&src2, the_repository->objects, b);
 
        merge_status = ll_merge(result_buf, path, &orig, base,
                                &src1, name1, &src2, name2,
index 586939939f24516e5ca5226323118904e46c63e4..47e9d7580a890c0c8ab065a11abe49b623e78ad0 100644 (file)
@@ -359,9 +359,9 @@ static int ll_merge_in_worktree(struct notes_merge_options *o,
        mmfile_t base, local, remote;
        enum ll_merge_result status;
 
-       read_mmblob(&base, &p->base);
-       read_mmblob(&local, &p->local);
-       read_mmblob(&remote, &p->remote);
+       read_mmblob(&base, the_repository->objects, &p->base);
+       read_mmblob(&local, the_repository->objects, &p->local);
+       read_mmblob(&remote, the_repository->objects, &p->remote);
 
        status = ll_merge(&result_buf, oid_to_hex(&p->obj), &base, NULL,
                          &local, o->local_ref, &remote, o->remote_ref,
index 1a35556380451afdc11c23cebddced162bd26795..f043330f2a12a00809226ce985e1c6da54ce26b1 100644 (file)
@@ -1,4 +1,3 @@
-#define USE_THE_REPOSITORY_VARIABLE
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
@@ -177,18 +176,19 @@ int read_mmfile(mmfile_t *ptr, const char *filename)
        return 0;
 }
 
-void read_mmblob(mmfile_t *ptr, const struct object_id *oid)
+void read_mmblob(mmfile_t *ptr, struct object_database *odb,
+                const struct object_id *oid)
 {
        unsigned long size;
        enum object_type type;
 
-       if (oideq(oid, null_oid(the_hash_algo))) {
+       if (is_null_oid(oid)) {
                ptr->ptr = xstrdup("");
                ptr->size = 0;
                return;
        }
 
-       ptr->ptr = odb_read_object(the_repository->objects, oid, &type, &size);
+       ptr->ptr = odb_read_object(odb, oid, &type, &size);
        if (!ptr->ptr || type != OBJ_BLOB)
                die("unable to read blob object %s", oid_to_hex(oid));
        ptr->size = size;
index dfc55daddf46ed8815ea10aa245eece0918bcb8d..fbc4ceec40eff51a9d72479689b8311fc12c4d8c 100644 (file)
@@ -4,6 +4,8 @@
 #include "hash.h"
 #include "xdiff/xdiff.h"
 
+struct object_database;
+
 /*
  * xdiff isn't equipped to handle content over a gigabyte;
  * we make the cutoff 1GB - 1MB to give some breathing
@@ -45,7 +47,8 @@ int xdi_diff_outf(mmfile_t *mf1, mmfile_t *mf2,
                  void *consume_callback_data,
                  xpparam_t const *xpp, xdemitconf_t const *xecfg);
 int read_mmfile(mmfile_t *ptr, const char *filename);
-void read_mmblob(mmfile_t *ptr, const struct object_id *oid);
+void read_mmblob(mmfile_t *ptr, struct object_database *odb,
+                const struct object_id *oid);
 int buffer_is_binary(const char *ptr, unsigned long size);
 
 void xdiff_set_find_func(xdemitconf_t *xecfg, const char *line, int cflags);