]> git.ipfire.org Git - thirdparty/git.git/blobdiff - merge-recursive.c
merge-recursive: fix the fix to the diff3 common ancestor label
[thirdparty/git.git] / merge-recursive.c
index 0231d7b04983d6c7f923122f14586dd565863d49..2653ba9a50c5d3c727e95ade81fcace7aba1d79a 100644 (file)
@@ -4,30 +4,31 @@
  * The thieves were Alex Riesen and Johannes Schindelin, in June/July 2006
  */
 #include "cache.h"
-#include "config.h"
+#include "merge-recursive.h"
+
 #include "advice.h"
-#include "lockfile.h"
-#include "cache-tree.h"
-#include "object-store.h"
-#include "repository.h"
-#include "commit.h"
+#include "alloc.h"
+#include "attr.h"
 #include "blob.h"
 #include "builtin.h"
-#include "tree-walk.h"
+#include "cache-tree.h"
+#include "commit.h"
+#include "commit-reach.h"
+#include "config.h"
 #include "diff.h"
 #include "diffcore.h"
+#include "dir.h"
+#include "ll-merge.h"
+#include "lockfile.h"
+#include "object-store.h"
+#include "repository.h"
+#include "revision.h"
+#include "string-list.h"
+#include "submodule.h"
 #include "tag.h"
-#include "alloc.h"
+#include "tree-walk.h"
 #include "unpack-trees.h"
-#include "string-list.h"
 #include "xdiff-interface.h"
-#include "ll-merge.h"
-#include "attr.h"
-#include "merge-recursive.h"
-#include "dir.h"
-#include "submodule.h"
-#include "revision.h"
-#include "commit-reach.h"
 
 struct merge_options_internal {
        int call_depth;
@@ -3549,6 +3550,8 @@ static int merge_recursive_internal(struct merge_options *opt,
                merged_merge_bases = make_virtual_commit(opt->repo, tree,
                                                         "ancestor");
                ancestor_name = "empty tree";
+       } else if (opt->ancestor && !opt->priv->call_depth) {
+               ancestor_name = opt->ancestor;
        } else if (merge_bases) {
                ancestor_name = "merged common ancestors";
        } else {
@@ -3597,6 +3600,7 @@ static int merge_recursive_internal(struct merge_options *opt,
                                                          merged_merge_bases),
                                     &result_tree);
        strbuf_release(&merge_base_abbrev);
+       opt->ancestor = NULL;  /* avoid accidental re-use of opt->ancestor */
        if (clean < 0) {
                flush_output(opt);
                return clean;
@@ -3688,7 +3692,8 @@ int merge_recursive(struct merge_options *opt,
 {
        int clean;
 
-       assert(opt->ancestor == NULL);
+       assert(opt->ancestor == NULL ||
+              !strcmp(opt->ancestor, "constructed merge base"));
 
        if (merge_start(opt, repo_get_commit_tree(opt->repo, h1)))
                return -1;
@@ -3740,6 +3745,8 @@ int merge_recursive_generic(struct merge_options *opt,
                                           oid_to_hex(merge_bases[i]));
                        commit_list_insert(base, &ca);
                }
+               if (num_merge_bases == 1)
+                       opt->ancestor = "constructed merge base";
        }
 
        repo_hold_locked_index(opt->repo, &lock, LOCK_DIE_ON_ERROR);