Skip to content

Commit

Permalink
xdl_merge(): introduce xmparam_t for merge specific parameters
Browse files Browse the repository at this point in the history
So far we have only needed to be able to pass an option that is generic to
xdiff family of functions to this function.  Extend the interface so that
we can give it merge specific parameters.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Junio C Hamano committed Jan 17, 2010
1 parent 7fb0eaa commit 00f8f97
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 12 deletions.
4 changes: 2 additions & 2 deletions builtin-merge-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)
const char *names[3] = { NULL, NULL, NULL };
mmfile_t mmfs[3];
mmbuffer_t result = {NULL, 0};
xpparam_t xpp = {XDF_NEED_MINIMAL};
xmparam_t xmp = {{XDF_NEED_MINIMAL}};
int ret = 0, i = 0, to_stdout = 0;
int merge_level = XDL_MERGE_ZEALOUS_ALNUM;
int merge_style = 0, quiet = 0;
Expand Down Expand Up @@ -68,7 +68,7 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)
}

ret = xdl_merge(mmfs + 1, mmfs + 0, names[0], mmfs + 2, names[2],
&xpp, merge_level | merge_style, &result);
&xmp, merge_level | merge_style, &result);

for (i = 0; i < 3; i++)
free(mmfs[i].ptr);
Expand Down
6 changes: 3 additions & 3 deletions ll-merge.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ static int ll_xdl_merge(const struct ll_merge_driver *drv_unused,
mmfile_t *src2, const char *name2,
int virtual_ancestor)
{
xpparam_t xpp;
xmparam_t xmp;
int style = 0;

if (buffer_is_binary(orig->ptr, orig->size) ||
Expand All @@ -76,13 +76,13 @@ static int ll_xdl_merge(const struct ll_merge_driver *drv_unused,
virtual_ancestor);
}

memset(&xpp, 0, sizeof(xpp));
memset(&xmp, 0, sizeof(xmp));
if (git_xmerge_style >= 0)
style = git_xmerge_style;
return xdl_merge(orig,
src1, name1,
src2, name2,
&xpp, XDL_MERGE_ZEALOUS | style,
&xmp, XDL_MERGE_ZEALOUS | style,
result);
}

Expand Down
6 changes: 3 additions & 3 deletions merge-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ static void free_mmfile(mmfile_t *f)
static void *three_way_filemerge(mmfile_t *base, mmfile_t *our, mmfile_t *their, unsigned long *size)
{
mmbuffer_t res;
xpparam_t xpp;
xmparam_t xmp;
int merge_status;

memset(&xpp, 0, sizeof(xpp));
memset(&xmp, 0, sizeof(xmp));
merge_status = xdl_merge(base, our, ".our", their, ".their",
&xpp, XDL_MERGE_ZEALOUS, &res);
&xmp, XDL_MERGE_ZEALOUS, &res);

if (merge_status < 0)
return NULL;
Expand Down
4 changes: 2 additions & 2 deletions rerere.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ static int merge(const char *name, const char *path)
int ret;
mmfile_t cur, base, other;
mmbuffer_t result = {NULL, 0};
xpparam_t xpp = {XDF_NEED_MINIMAL};
xmparam_t xmp = {{XDF_NEED_MINIMAL}};

if (handle_file(path, NULL, rerere_path(name, "thisimage")) < 0)
return 1;
Expand All @@ -342,7 +342,7 @@ static int merge(const char *name, const char *path)
read_mmfile(&other, rerere_path(name, "postimage")))
return 1;
ret = xdl_merge(&base, &cur, "", &other, "",
&xpp, XDL_MERGE_ZEALOUS, &result);
&xmp, XDL_MERGE_ZEALOUS, &result);
if (!ret) {
FILE *f = fopen(path, "w");
if (!f)
Expand Down
6 changes: 5 additions & 1 deletion xdiff/xdiff.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,13 @@ long xdl_mmfile_size(mmfile_t *mmf);
int xdl_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp,
xdemitconf_t const *xecfg, xdemitcb_t *ecb);

typedef struct s_xmparam {
xpparam_t xpp;
} xmparam_t;

int xdl_merge(mmfile_t *orig, mmfile_t *mf1, const char *name1,
mmfile_t *mf2, const char *name2,
xpparam_t const *xpp, int level, mmbuffer_t *result);
xmparam_t const *xmp, int level, mmbuffer_t *result);

#ifdef __cplusplus
}
Expand Down
3 changes: 2 additions & 1 deletion xdiff/xmerge.c
Original file line number Diff line number Diff line change
Expand Up @@ -538,10 +538,11 @@ static int xdl_do_merge(xdfenv_t *xe1, xdchange_t *xscr1, const char *name1,

int xdl_merge(mmfile_t *orig, mmfile_t *mf1, const char *name1,
mmfile_t *mf2, const char *name2,
xpparam_t const *xpp, int flags, mmbuffer_t *result) {
xmparam_t const *xmp, int flags, mmbuffer_t *result) {
xdchange_t *xscr1, *xscr2;
xdfenv_t xe1, xe2;
int status;
xpparam_t const *xpp = &xmp->xpp;

result->ptr = NULL;
result->size = 0;
Expand Down

0 comments on commit 00f8f97

Please sign in to comment.