From: Junio C Hamano Date: Fri, 26 Feb 2016 21:37:14 +0000 (-0800) Subject: Merge branch 'jk/no-diff-emit-common' X-Git-Tag: v2.8.0-rc0~21 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/18b26b18c50637eaa8fb1ae5f42fd94c8ac99507?hp=-c Merge branch 'jk/no-diff-emit-common' "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 --- 18b26b18c50637eaa8fb1ae5f42fd94c8ac99507 diff --combined git-merge-one-file.sh index cdc02af517,b8bab75485..424b034e34 --- a/git-merge-one-file.sh +++ b/git-merge-one-file.sh @@@ -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" @@@ -120,8 -112,7 +120,7 @@@ 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 ddca601c77,4f68537a73..9b6eac22e4 --- a/merge-blobs.c +++ b/merge-blobs.c @@@ -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; @@@ -100,7 -66,7 +66,7 @@@ 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) @@@ -112,8 -78,8 +78,8 @@@ 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);