neue: remove a bogus empty file
[git/gitster.git] / merge-ort-wrappers.c
blob4acedf3c3386d7c9c2e57eebabddb1fe9ec27331
1 #include "git-compat-util.h"
2 #include "gettext.h"
3 #include "hash.h"
4 #include "merge-ort.h"
5 #include "merge-ort-wrappers.h"
6 #include "read-cache-ll.h"
7 #include "tree.h"
9 #include "commit.h"
11 static int unclean(struct merge_options *opt, struct tree *head)
13 /* Sanity check on repo state; index must match head */
14 struct strbuf sb = STRBUF_INIT;
16 if (head && repo_index_has_changes(opt->repo, head, &sb)) {
17 error(_("Your local changes to the following files would be overwritten by merge:\n %s"),
18 sb.buf);
19 strbuf_release(&sb);
20 return -1;
23 return 0;
26 int merge_ort_nonrecursive(struct merge_options *opt,
27 struct tree *head,
28 struct tree *merge,
29 struct tree *merge_base)
31 struct merge_result result;
33 if (unclean(opt, head))
34 return -1;
36 if (oideq(&merge_base->object.oid, &merge->object.oid)) {
37 printf_ln(_("Already up to date."));
38 return 1;
41 memset(&result, 0, sizeof(result));
42 merge_incore_nonrecursive(opt, merge_base, head, merge, &result);
43 merge_switch_to_result(opt, head, &result, 1, 1);
45 return result.clean;
48 int merge_ort_recursive(struct merge_options *opt,
49 struct commit *side1,
50 struct commit *side2,
51 struct commit_list *merge_bases,
52 struct commit **result)
54 struct tree *head = repo_get_commit_tree(opt->repo, side1);
55 struct merge_result tmp;
57 if (unclean(opt, head))
58 return -1;
60 memset(&tmp, 0, sizeof(tmp));
61 merge_incore_recursive(opt, merge_bases, side1, side2, &tmp);
62 merge_switch_to_result(opt, head, &tmp, 1, 1);
63 *result = NULL;
65 return tmp.clean;