Skip to content

Commit 00f8f97

Browse files
committed
xdl_merge(): introduce xmparam_t for merge specific parameters
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 <[email protected]>
1 parent 7fb0eaa commit 00f8f97

File tree

6 files changed

+17
-12
lines changed

6 files changed

+17
-12
lines changed

builtin-merge-file.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)
2525
const char *names[3] = { NULL, NULL, NULL };
2626
mmfile_t mmfs[3];
2727
mmbuffer_t result = {NULL, 0};
28-
xpparam_t xpp = {XDF_NEED_MINIMAL};
28+
xmparam_t xmp = {{XDF_NEED_MINIMAL}};
2929
int ret = 0, i = 0, to_stdout = 0;
3030
int merge_level = XDL_MERGE_ZEALOUS_ALNUM;
3131
int merge_style = 0, quiet = 0;
@@ -68,7 +68,7 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)
6868
}
6969

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

7373
for (i = 0; i < 3; i++)
7474
free(mmfs[i].ptr);

ll-merge.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ static int ll_xdl_merge(const struct ll_merge_driver *drv_unused,
6161
mmfile_t *src2, const char *name2,
6262
int virtual_ancestor)
6363
{
64-
xpparam_t xpp;
64+
xmparam_t xmp;
6565
int style = 0;
6666

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

79-
memset(&xpp, 0, sizeof(xpp));
79+
memset(&xmp, 0, sizeof(xmp));
8080
if (git_xmerge_style >= 0)
8181
style = git_xmerge_style;
8282
return xdl_merge(orig,
8383
src1, name1,
8484
src2, name2,
85-
&xpp, XDL_MERGE_ZEALOUS | style,
85+
&xmp, XDL_MERGE_ZEALOUS | style,
8686
result);
8787
}
8888

merge-file.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ static void free_mmfile(mmfile_t *f)
2727
static void *three_way_filemerge(mmfile_t *base, mmfile_t *our, mmfile_t *their, unsigned long *size)
2828
{
2929
mmbuffer_t res;
30-
xpparam_t xpp;
30+
xmparam_t xmp;
3131
int merge_status;
3232

33-
memset(&xpp, 0, sizeof(xpp));
33+
memset(&xmp, 0, sizeof(xmp));
3434
merge_status = xdl_merge(base, our, ".our", their, ".their",
35-
&xpp, XDL_MERGE_ZEALOUS, &res);
35+
&xmp, XDL_MERGE_ZEALOUS, &res);
3636

3737
if (merge_status < 0)
3838
return NULL;

rerere.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ static int merge(const char *name, const char *path)
332332
int ret;
333333
mmfile_t cur, base, other;
334334
mmbuffer_t result = {NULL, 0};
335-
xpparam_t xpp = {XDF_NEED_MINIMAL};
335+
xmparam_t xmp = {{XDF_NEED_MINIMAL}};
336336

337337
if (handle_file(path, NULL, rerere_path(name, "thisimage")) < 0)
338338
return 1;
@@ -342,7 +342,7 @@ static int merge(const char *name, const char *path)
342342
read_mmfile(&other, rerere_path(name, "postimage")))
343343
return 1;
344344
ret = xdl_merge(&base, &cur, "", &other, "",
345-
&xpp, XDL_MERGE_ZEALOUS, &result);
345+
&xmp, XDL_MERGE_ZEALOUS, &result);
346346
if (!ret) {
347347
FILE *f = fopen(path, "w");
348348
if (!f)

xdiff/xdiff.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,13 @@ long xdl_mmfile_size(mmfile_t *mmf);
108108
int xdl_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp,
109109
xdemitconf_t const *xecfg, xdemitcb_t *ecb);
110110

111+
typedef struct s_xmparam {
112+
xpparam_t xpp;
113+
} xmparam_t;
114+
111115
int xdl_merge(mmfile_t *orig, mmfile_t *mf1, const char *name1,
112116
mmfile_t *mf2, const char *name2,
113-
xpparam_t const *xpp, int level, mmbuffer_t *result);
117+
xmparam_t const *xmp, int level, mmbuffer_t *result);
114118

115119
#ifdef __cplusplus
116120
}

xdiff/xmerge.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,10 +538,11 @@ static int xdl_do_merge(xdfenv_t *xe1, xdchange_t *xscr1, const char *name1,
538538

539539
int xdl_merge(mmfile_t *orig, mmfile_t *mf1, const char *name1,
540540
mmfile_t *mf2, const char *name2,
541-
xpparam_t const *xpp, int flags, mmbuffer_t *result) {
541+
xmparam_t const *xmp, int flags, mmbuffer_t *result) {
542542
xdchange_t *xscr1, *xscr2;
543543
xdfenv_t xe1, xe2;
544544
int status;
545+
xpparam_t const *xpp = &xmp->xpp;
545546

546547
result->ptr = NULL;
547548
result->size = 0;

0 commit comments

Comments
 (0)