1 #include "git-compat-util.h"
4 #include "merge-blobs.h"
5 #include "object-store-ll.h"
7 static int fill_mmfile_blob(mmfile_t
*f
, struct blob
*obj
)
11 enum object_type type
;
13 buf
= repo_read_object_file(the_repository
, &obj
->object
.oid
, &type
,
17 if (type
!= OBJ_BLOB
) {
26 static void free_mmfile(mmfile_t
*f
)
31 static void *three_way_filemerge(struct index_state
*istate
,
38 enum ll_merge_result merge_status
;
42 * This function is only used by cmd_merge_tree, which
43 * does not respect the merge.conflictstyle option.
44 * There is no need to worry about a label for the
47 merge_status
= ll_merge(&res
, path
, base
, NULL
,
48 our
, ".our", their
, ".their",
52 if (merge_status
== LL_MERGE_BINARY_CONFLICT
)
53 warning("Cannot merge binary files: %s (%s vs. %s)",
54 path
, ".our", ".their");
60 void *merge_blobs(struct index_state
*istate
, const char *path
,
61 struct blob
*base
, struct blob
*our
,
62 struct blob
*their
, unsigned long *size
)
65 mmfile_t f1
, f2
, common
;
68 * Removed in either branch?
70 * NOTE! This depends on the caller having done the
71 * proper warning about removing a file that got
72 * modified in the other branch!
75 enum object_type type
;
80 return repo_read_object_file(the_repository
, &our
->object
.oid
,
84 if (fill_mmfile_blob(&f1
, our
) < 0)
86 if (fill_mmfile_blob(&f2
, their
) < 0)
90 if (fill_mmfile_blob(&common
, base
) < 0)
93 common
.ptr
= xstrdup("");
96 res
= three_way_filemerge(istate
, path
, &common
, &f1
, &f2
, size
);