Skip to content

Commit af5706f

Browse files
rscharfegitster
authored andcommitted
xdiff-interface: stop using the_repository
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>
1 parent 67ad421 commit af5706f

7 files changed

Lines changed: 21 additions & 18 deletions

File tree

apply.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3568,9 +3568,9 @@ static int three_way_merge(struct apply_state *state,
35683568
else if (oideq(base, theirs) || oideq(ours, theirs))
35693569
return resolve_to(image, ours);
35703570

3571-
read_mmblob(&base_file, base);
3572-
read_mmblob(&our_file, ours);
3573-
read_mmblob(&their_file, theirs);
3571+
read_mmblob(&base_file, the_repository->objects, base);
3572+
read_mmblob(&our_file, the_repository->objects, ours);
3573+
read_mmblob(&their_file, the_repository->objects, theirs);
35743574
merge_opts.variant = state->merge_variant;
35753575
status = ll_merge(&result, path,
35763576
&base_file, "base",

builtin/checkout.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,9 @@ static int checkout_merged(int pos, const struct checkout *state,
294294
if (is_null_oid(&threeway[1]) || is_null_oid(&threeway[2]))
295295
return error(_("path '%s' does not have necessary versions"), path);
296296

297-
read_mmblob(&ancestor, &threeway[0]);
298-
read_mmblob(&ours, &threeway[1]);
299-
read_mmblob(&theirs, &threeway[2]);
297+
read_mmblob(&ancestor, the_repository->objects, &threeway[0]);
298+
read_mmblob(&ours, the_repository->objects, &threeway[1]);
299+
read_mmblob(&theirs, the_repository->objects, &threeway[2]);
300300

301301
repo_config_get_bool(the_repository, "merge.renormalize", &renormalize);
302302
ll_opts.renormalize = renormalize;

builtin/merge-file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ int cmd_merge_file(int argc,
128128
ret = error(_("object '%s' does not exist"),
129129
argv[i]);
130130
else if (!oideq(&oid, the_hash_algo->empty_blob))
131-
read_mmblob(mmf, &oid);
131+
read_mmblob(mmf, the_repository->objects, &oid);
132132
else
133133
read_mmfile(mmf, "/dev/null");
134134
} else if (read_mmfile(mmf, fname)) {

merge-ort.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2136,9 +2136,9 @@ static int merge_3way(struct merge_options *opt,
21362136
name2 = mkpathdup("%s:%s", opt->branch2, pathnames[2]);
21372137
}
21382138

2139-
read_mmblob(&orig, o);
2140-
read_mmblob(&src1, a);
2141-
read_mmblob(&src2, b);
2139+
read_mmblob(&orig, the_repository->objects, o);
2140+
read_mmblob(&src1, the_repository->objects, a);
2141+
read_mmblob(&src2, the_repository->objects, b);
21422142

21432143
merge_status = ll_merge(result_buf, path, &orig, base,
21442144
&src1, name1, &src2, name2,

notes-merge.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -359,9 +359,9 @@ static int ll_merge_in_worktree(struct notes_merge_options *o,
359359
mmfile_t base, local, remote;
360360
enum ll_merge_result status;
361361

362-
read_mmblob(&base, &p->base);
363-
read_mmblob(&local, &p->local);
364-
read_mmblob(&remote, &p->remote);
362+
read_mmblob(&base, the_repository->objects, &p->base);
363+
read_mmblob(&local, the_repository->objects, &p->local);
364+
read_mmblob(&remote, the_repository->objects, &p->remote);
365365

366366
status = ll_merge(&result_buf, oid_to_hex(&p->obj), &base, NULL,
367367
&local, o->local_ref, &remote, o->remote_ref,

xdiff-interface.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#define USE_THE_REPOSITORY_VARIABLE
21
#define DISABLE_SIGN_COMPARE_WARNINGS
32

43
#include "git-compat-util.h"
@@ -177,18 +176,19 @@ int read_mmfile(mmfile_t *ptr, const char *filename)
177176
return 0;
178177
}
179178

180-
void read_mmblob(mmfile_t *ptr, const struct object_id *oid)
179+
void read_mmblob(mmfile_t *ptr, struct object_database *odb,
180+
const struct object_id *oid)
181181
{
182182
unsigned long size;
183183
enum object_type type;
184184

185-
if (oideq(oid, null_oid(the_hash_algo))) {
185+
if (is_null_oid(oid)) {
186186
ptr->ptr = xstrdup("");
187187
ptr->size = 0;
188188
return;
189189
}
190190

191-
ptr->ptr = odb_read_object(the_repository->objects, oid, &type, &size);
191+
ptr->ptr = odb_read_object(odb, oid, &type, &size);
192192
if (!ptr->ptr || type != OBJ_BLOB)
193193
die("unable to read blob object %s", oid_to_hex(oid));
194194
ptr->size = size;

xdiff-interface.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#include "hash.h"
55
#include "xdiff/xdiff.h"
66

7+
struct object_database;
8+
79
/*
810
* xdiff isn't equipped to handle content over a gigabyte;
911
* we make the cutoff 1GB - 1MB to give some breathing
@@ -45,7 +47,8 @@ int xdi_diff_outf(mmfile_t *mf1, mmfile_t *mf2,
4547
void *consume_callback_data,
4648
xpparam_t const *xpp, xdemitconf_t const *xecfg);
4749
int read_mmfile(mmfile_t *ptr, const char *filename);
48-
void read_mmblob(mmfile_t *ptr, const struct object_id *oid);
50+
void read_mmblob(mmfile_t *ptr, struct object_database *odb,
51+
const struct object_id *oid);
4952
int buffer_is_binary(const char *ptr, unsigned long size);
5053

5154
void xdiff_set_find_func(xdemitconf_t *xecfg, const char *line, int cflags);

0 commit comments

Comments
 (0)