Merge branch 'jk/no-diff-emit-common' into maint
authorJunio C Hamano <gitster@pobox.com>
Thu, 10 Mar 2016 19:13:41 +0000 (11:13 -0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 10 Mar 2016 19:13:42 +0000 (11:13 -0800)
"git merge-tree" used to mishandle "both sides added" conflict with
its own "create a fake ancestor file that has the common parts of
what both sides have added and do a 3-way merge" logic; this has
been updated to use the usual "3-way merge with an empty blob as
the fake common ancestor file" approach used in the rest of the
system.

* jk/no-diff-emit-common:
xdiff: drop XDL_EMIT_COMMON
merge-tree: drop generate_common strategy
merge-one-file: use empty blob for add/add base

1  2 
git-merge-one-file.sh
merge-blobs.c
diff --combined git-merge-one-file.sh
index cdc02af517c9d77a081d7918480f8d0a2c6a29d0,b8bab75485711892e80b3140d41d6607fd1f0324..424b034e34b4b40e7c44da16ddf83a31dee6f6a0
@@@ -38,14 -38,6 +38,14 @@@ case "${1:-.}${2:-.}${3:-.}" i
  # Deleted in both or deleted in one and unchanged in the other
  #
  "$1.." | "$1.$1" | "$1$1.")
 +      if { test -z "$6" && test "$5" != "$7"; } ||
 +         { test -z "$7" && test "$5" != "$6"; }
 +      then
 +              echo "ERROR: File $4 deleted on one branch but had its" >&2
 +              echo "ERROR: permissions changed on the other." >&2
 +              exit 1
 +      fi
 +
        if test -n "$2"
        then
                echo "Removing $4"
        case "$1" in
        '')
                echo "Added $4 in both, but differently."
-               orig=$(git-unpack-file $2)
-               create_virtual_base "$orig" "$src2"
+               orig=$(git-unpack-file e69de29bb2d1d6434b8b29ae775ad8c2e48c5391)
                ;;
        *)
                echo "Auto-merging $4"
diff --combined merge-blobs.c
index ddca601c77fcab7d9d68362ce5c4f252ab7ccf51,4f68537a732dedbefe34d19d2089c743f44e01ae..9b6eac22e4256d8f2bf82961b6e4f320d89fdeba
@@@ -11,7 -11,7 +11,7 @@@ static int fill_mmfile_blob(mmfile_t *f
        unsigned long size;
        enum object_type type;
  
 -      buf = read_sha1_file(obj->object.sha1, &type, &size);
 +      buf = read_sha1_file(obj->object.oid.hash, &type, &size);
        if (!buf)
                return -1;
        if (type != OBJ_BLOB) {
@@@ -48,40 -48,6 +48,6 @@@ static void *three_way_filemerge(const 
        return res.ptr;
  }
  
- static int common_outf(void *priv_, mmbuffer_t *mb, int nbuf)
- {
-       int i;
-       mmfile_t *dst = priv_;
-       for (i = 0; i < nbuf; i++) {
-               memcpy(dst->ptr + dst->size, mb[i].ptr, mb[i].size);
-               dst->size += mb[i].size;
-       }
-       return 0;
- }
- static int generate_common_file(mmfile_t *res, mmfile_t *f1, mmfile_t *f2)
- {
-       unsigned long size = f1->size < f2->size ? f1->size : f2->size;
-       void *ptr = xmalloc(size);
-       xpparam_t xpp;
-       xdemitconf_t xecfg;
-       xdemitcb_t ecb;
-       memset(&xpp, 0, sizeof(xpp));
-       xpp.flags = 0;
-       memset(&xecfg, 0, sizeof(xecfg));
-       xecfg.ctxlen = 3;
-       xecfg.flags = XDL_EMIT_COMMON;
-       ecb.outf = common_outf;
-       res->ptr = ptr;
-       res->size = 0;
-       ecb.priv = res;
-       return xdi_diff(f1, f2, &xpp, &xecfg, &ecb);
- }
  void *merge_blobs(const char *path, struct blob *base, struct blob *our, struct blob *their, unsigned long *size)
  {
        void *res = NULL;
                        return NULL;
                if (!our)
                        our = their;
 -              return read_sha1_file(our->object.sha1, &type, size);
 +              return read_sha1_file(our->object.oid.hash, &type, size);
        }
  
        if (fill_mmfile_blob(&f1, our) < 0)
                if (fill_mmfile_blob(&common, base) < 0)
                        goto out_free_f2_f1;
        } else {
-               if (generate_common_file(&common, &f1, &f2) < 0)
-                       goto out_free_f2_f1;
+               common.ptr = xstrdup("");
+               common.size = 0;
        }
        res = three_way_filemerge(path, &common, &f1, &f2, size);
        free_mmfile(&common);