mirror of
https://github.com/git/git.git
synced 2024-09-26 01:01:06 +02:00
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
This commit is contained in:
commit
18b26b18c5
@ -120,8 +120,7 @@ case "${1:-.}${2:-.}${3:-.}" in
|
|||||||
case "$1" in
|
case "$1" in
|
||||||
'')
|
'')
|
||||||
echo "Added $4 in both, but differently."
|
echo "Added $4 in both, but differently."
|
||||||
orig=$(git-unpack-file $2)
|
orig=$(git-unpack-file e69de29bb2d1d6434b8b29ae775ad8c2e48c5391)
|
||||||
create_virtual_base "$orig" "$src2"
|
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Auto-merging $4"
|
echo "Auto-merging $4"
|
||||||
|
@ -48,40 +48,6 @@ static void *three_way_filemerge(const char *path, mmfile_t *base, mmfile_t *our
|
|||||||
return res.ptr;
|
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 *merge_blobs(const char *path, struct blob *base, struct blob *our, struct blob *their, unsigned long *size)
|
||||||
{
|
{
|
||||||
void *res = NULL;
|
void *res = NULL;
|
||||||
@ -112,8 +78,8 @@ void *merge_blobs(const char *path, struct blob *base, struct blob *our, struct
|
|||||||
if (fill_mmfile_blob(&common, base) < 0)
|
if (fill_mmfile_blob(&common, base) < 0)
|
||||||
goto out_free_f2_f1;
|
goto out_free_f2_f1;
|
||||||
} else {
|
} else {
|
||||||
if (generate_common_file(&common, &f1, &f2) < 0)
|
common.ptr = xstrdup("");
|
||||||
goto out_free_f2_f1;
|
common.size = 0;
|
||||||
}
|
}
|
||||||
res = three_way_filemerge(path, &common, &f1, &f2, size);
|
res = three_way_filemerge(path, &common, &f1, &f2, size);
|
||||||
free_mmfile(&common);
|
free_mmfile(&common);
|
||||||
|
@ -42,7 +42,6 @@ extern "C" {
|
|||||||
#define XDF_IGNORE_BLANK_LINES (1 << 7)
|
#define XDF_IGNORE_BLANK_LINES (1 << 7)
|
||||||
|
|
||||||
#define XDL_EMIT_FUNCNAMES (1 << 0)
|
#define XDL_EMIT_FUNCNAMES (1 << 0)
|
||||||
#define XDL_EMIT_COMMON (1 << 1)
|
|
||||||
#define XDL_EMIT_FUNCCONTEXT (1 << 2)
|
#define XDL_EMIT_FUNCCONTEXT (1 << 2)
|
||||||
|
|
||||||
#define XDL_MMB_READONLY (1 << 0)
|
#define XDL_MMB_READONLY (1 << 0)
|
||||||
|
@ -120,21 +120,6 @@ static long def_ff(const char *rec, long len, char *buf, long sz, void *priv)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int xdl_emit_common(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb,
|
|
||||||
xdemitconf_t const *xecfg) {
|
|
||||||
xdfile_t *xdf = &xe->xdf2;
|
|
||||||
const char *rchg = xdf->rchg;
|
|
||||||
long ix;
|
|
||||||
|
|
||||||
for (ix = 0; ix < xdf->nrec; ix++) {
|
|
||||||
if (rchg[ix])
|
|
||||||
continue;
|
|
||||||
if (xdl_emit_record(xdf, ix, "", ecb))
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct func_line {
|
struct func_line {
|
||||||
long len;
|
long len;
|
||||||
char buf[80];
|
char buf[80];
|
||||||
@ -170,9 +155,6 @@ int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb,
|
|||||||
long funclineprev = -1;
|
long funclineprev = -1;
|
||||||
struct func_line func_line = { 0 };
|
struct func_line func_line = { 0 };
|
||||||
|
|
||||||
if (xecfg->flags & XDL_EMIT_COMMON)
|
|
||||||
return xdl_emit_common(xe, xscr, ecb, xecfg);
|
|
||||||
|
|
||||||
for (xch = xscr; xch; xch = xche->next) {
|
for (xch = xscr; xch; xch = xche->next) {
|
||||||
xche = xdl_get_hunk(&xch, xecfg);
|
xche = xdl_get_hunk(&xch, xecfg);
|
||||||
if (!xch)
|
if (!xch)
|
||||||
|
Loading…
Reference in New Issue
Block a user