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 <gitster@pobox.com>
Junio C Hamano committed
Jan 16, 2010 at 21:01 UTC
00f8f97d30be7992c16bc466532cb591e00314bf
6 files changed
+17
-12
builtin-merge-file.c
+2
-2
@@ -25,7 +25,7 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)
25
const char *names[3] = { NULL, NULL, NULL };
26
mmfile_t mmfs[3];
27
mmbuffer_t result = {NULL, 0};
28
- xpparam_t xpp = {XDF_NEED_MINIMAL};
28
+ xmparam_t xmp = {{XDF_NEED_MINIMAL}};
29
int ret = 0, i = 0, to_stdout = 0;
30
int merge_level = XDL_MERGE_ZEALOUS_ALNUM;
31
int merge_style = 0, quiet = 0;
@@ -68,7 +68,7 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)
68
}
69
70
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);
72
73
for (i = 0; i < 3; i++)
74
free(mmfs[i].ptr);
ll-merge.c
+3
-3
@@ -61,7 +61,7 @@ static int ll_xdl_merge(const struct ll_merge_driver *drv_unused,
61
mmfile_t *src2, const char *name2,
62
int virtual_ancestor)
63
{
64
- xpparam_t xpp;
64
+ xmparam_t xmp;
65
int style = 0;
66
67
if (buffer_is_binary(orig->ptr, orig->size) ||
@@ -76,13 +76,13 @@ static int ll_xdl_merge(const struct ll_merge_driver *drv_unused,
76
virtual_ancestor);
77
}
78
79
- memset(&xpp, 0, sizeof(xpp));
79
+ memset(&xmp, 0, sizeof(xmp));
80
if (git_xmerge_style >= 0)
81
style = git_xmerge_style;
82
return xdl_merge(orig,
83
src1, name1,
84
src2, name2,
85
- &xpp, XDL_MERGE_ZEALOUS | style,
85
+ &xmp, XDL_MERGE_ZEALOUS | style,
86
result);
87
}
88
merge-file.c
+3
-3
@@ -27,12 +27,12 @@ static void free_mmfile(mmfile_t *f)
27
static void *three_way_filemerge(mmfile_t *base, mmfile_t *our, mmfile_t *their, unsigned long *size)
28
{
29
mmbuffer_t res;
30
- xpparam_t xpp;
30
+ xmparam_t xmp;
31
int merge_status;
32
33
- memset(&xpp, 0, sizeof(xpp));
33
+ memset(&xmp, 0, sizeof(xmp));
34
merge_status = xdl_merge(base, our, ".our", their, ".their",
35
- &xpp, XDL_MERGE_ZEALOUS, &res);
35
+ &xmp, XDL_MERGE_ZEALOUS, &res);
36
37
if (merge_status < 0)
38
return NULL;
rerere.c
+2
-2
@@ -332,7 +332,7 @@ static int merge(const char *name, const char *path)
332
int ret;
333
mmfile_t cur, base, other;
334
mmbuffer_t result = {NULL, 0};
335
- xpparam_t xpp = {XDF_NEED_MINIMAL};
335
+ xmparam_t xmp = {{XDF_NEED_MINIMAL}};
336
337
if (handle_file(path, NULL, rerere_path(name, "thisimage")) < 0)
338
return 1;
@@ -342,7 +342,7 @@ static int merge(const char *name, const char *path)
342
read_mmfile(&other, rerere_path(name, "postimage")))
343
return 1;
344
ret = xdl_merge(&base, &cur, "", &other, "",
345
- &xpp, XDL_MERGE_ZEALOUS, &result);
345
+ &xmp, XDL_MERGE_ZEALOUS, &result);
346
if (!ret) {
347
FILE *f = fopen(path, "w");
348
if (!f)
xdiff/xdiff.h
+5
-1
@@ -108,9 +108,13 @@ long xdl_mmfile_size(mmfile_t *mmf);
108
int xdl_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp,
109
xdemitconf_t const *xecfg, xdemitcb_t *ecb);
110
111
+typedef struct s_xmparam {
112
+ xpparam_t xpp;
113
+} xmparam_t;
114
+
115
int xdl_merge(mmfile_t *orig, mmfile_t *mf1, const char *name1,
116
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);
118
119
#ifdef __cplusplus
120
}
xdiff/xmerge.c
+2
-1
@@ -538,10 +538,11 @@ static int xdl_do_merge(xdfenv_t *xe1, xdchange_t *xscr1, const char *name1,
538
539
int xdl_merge(mmfile_t *orig, mmfile_t *mf1, const char *name1,
540
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) {
542
xdchange_t *xscr1, *xscr2;
543
xdfenv_t xe1, xe2;
544
int status;
545
+ xpparam_t const *xpp = &xmp->xpp;
546
547
result->ptr = NULL;
548
result->size = 0;