1 #define USE_THE_REPOSITORY_VARIABLE
3 #include "git-compat-util.h"
6 #include "merge-blobs.h"
7 #include "object-store-ll.h"
9 static int fill_mmfile_blob(mmfile_t
*f
, struct blob
*obj
)
13 enum object_type type
;
15 buf
= repo_read_object_file(the_repository
, &obj
->object
.oid
, &type
,
19 if (type
!= OBJ_BLOB
) {
28 static void free_mmfile(mmfile_t
*f
)
33 static void *three_way_filemerge(struct index_state
*istate
,
40 enum ll_merge_result merge_status
;
44 * This function is only used by cmd_merge_tree, which
45 * does not respect the merge.conflictstyle option.
46 * There is no need to worry about a label for the
49 merge_status
= ll_merge(&res
, path
, base
, NULL
,
50 our
, ".our", their
, ".their",
54 if (merge_status
== LL_MERGE_BINARY_CONFLICT
)
55 warning("Cannot merge binary files: %s (%s vs. %s)",
56 path
, ".our", ".their");
62 void *merge_blobs(struct index_state
*istate
, const char *path
,
63 struct blob
*base
, struct blob
*our
,
64 struct blob
*their
, unsigned long *size
)
67 mmfile_t f1
, f2
, common
;
70 * Removed in either branch?
72 * NOTE! This depends on the caller having done the
73 * proper warning about removing a file that got
74 * modified in the other branch!
77 enum object_type type
;
82 return repo_read_object_file(the_repository
, &our
->object
.oid
,
86 if (fill_mmfile_blob(&f1
, our
) < 0)
88 if (fill_mmfile_blob(&f2
, their
) < 0)
92 if (fill_mmfile_blob(&common
, base
) < 0)
95 common
.ptr
= xstrdup("");
98 res
= three_way_filemerge(istate
, path
, &common
, &f1
, &f2
, size
);