Future-proof source for changes in xdemitconf_t
The instances of xdemitconf_t were initialized member by member. Instead, initialize them to all zero, so we do not have to update those places each time we introduce a new member. [jc: minimally fixed by getting rid of a new global] Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Schindelin committed
Jul 4, 2007 at 19:05 UTC
30b250104d9307e1225031c7fc39b66643265ed1
6 files changed
+10
-10
builtin-blame.c
+1
-1
@@ -518,8 +518,8 @@ static struct patch *compare_buffer(mmfile_t *file_p, mmfile_t *file_o,
518
xdemitcb_t ecb;
519
520
xpp.flags = xdl_opts;
521
+ memset(&xecfg, 0, sizeof(xecfg));
522
xecfg.ctxlen = context;
522
- xecfg.flags = 0;
523
ecb.outf = xdiff_outf;
524
ecb.priv = &state;
525
memset(&state, 0, sizeof(state));
builtin-rerere.c
+1
-1
@@ -282,8 +282,8 @@ static int diff_two(const char *file1, const char *label1,
282
printf("--- a/%s\n+++ b/%s\n", label1, label2);
283
fflush(stdout);
284
xpp.flags = XDF_NEED_MINIMAL;
285
+ memset(&xecfg, 0, sizeof(xecfg));
286
xecfg.ctxlen = 3;
286
- xecfg.flags = 0;
287
ecb.outf = outf;
288
xdl_diff(&minus, &plus, &xpp, &xecfg, &ecb);
289
combine-diff.c
+1
-2
@@ -215,8 +215,7 @@ static void combine_diff(const unsigned char *parent, mmfile_t *result_file,
215
parent_file.ptr = grab_blob(parent, &sz);
216
parent_file.size = sz;
217
xpp.flags = XDF_NEED_MINIMAL;
218
- xecfg.ctxlen = 0;
219
- xecfg.flags = 0;
218
+ memset(&xecfg, 0, sizeof(xecfg));
219
ecb.outf = xdiff_outf;
220
ecb.priv = &state;
221
memset(&state, 0, sizeof(state));
diff.c
+5
-5
@@ -390,6 +390,7 @@ static void diff_words_show(struct diff_words_data *diff_words)
390
mmfile_t minus, plus;
391
int i;
392
393
+ memset(&xecfg, 0, sizeof(xecfg));
394
minus.size = diff_words->minus.text.size;
395
minus.ptr = xmalloc(minus.size);
396
memcpy(minus.ptr, diff_words->minus.text.ptr, minus.size);
@@ -408,7 +409,6 @@ static void diff_words_show(struct diff_words_data *diff_words)
409
410
xpp.flags = XDF_NEED_MINIMAL;
411
xecfg.ctxlen = diff_words->minus.alloc + diff_words->plus.alloc;
411
- xecfg.flags = 0;
412
ecb.outf = xdiff_outf;
413
ecb.priv = diff_words;
414
diff_words->xm.consume = fn_out_diff_words_aux;
@@ -1218,6 +1218,7 @@ static void builtin_diff(const char *name_a,
1218
xdemitcb_t ecb;
1219
struct emit_callback ecbdata;
1220
1221
+ memset(&xecfg, 0, sizeof(xecfg));
1222
memset(&ecbdata, 0, sizeof(ecbdata));
1223
ecbdata.label_path = lbl;
1224
ecbdata.color_diff = o->color_diff;
@@ -1286,9 +1287,8 @@ static void builtin_diffstat(const char *name_a, const char *name_b,
1287
xdemitconf_t xecfg;
1288
xdemitcb_t ecb;
1289
1290
+ memset(&xecfg, 0, sizeof(xecfg));
1291
xpp.flags = XDF_NEED_MINIMAL | o->xdl_opts;
1290
- xecfg.ctxlen = 0;
1291
- xecfg.flags = 0;
1292
ecb.outf = xdiff_outf;
1293
ecb.priv = diffstat;
1294
xdl_diff(&mf1, &mf2, &xpp, &xecfg, &ecb);
@@ -1326,9 +1326,8 @@ static void builtin_checkdiff(const char *name_a, const char *name_b,
1326
xdemitconf_t xecfg;
1327
xdemitcb_t ecb;
1328
1329
+ memset(&xecfg, 0, sizeof(xecfg));
1330
xpp.flags = XDF_NEED_MINIMAL;
1330
- xecfg.ctxlen = 0;
1331
- xecfg.flags = 0;
1331
ecb.outf = xdiff_outf;
1332
ecb.priv = &data;
1333
xdl_diff(&mf1, &mf2, &xpp, &xecfg, &ecb);
@@ -2780,6 +2779,7 @@ static int diff_get_patch_id(struct diff_options *options, unsigned char *sha1)
2779
struct diff_filepair *p = q->queue[i];
2780
int len1, len2;
2781
2782
+ memset(&xecfg, 0, sizeof(xecfg));
2783
if (p->status == 0)
2784
return error("internal diff status error");
2785
if (p->status == DIFF_STATUS_UNKNOWN)
merge-file.c
+1
@@ -62,6 +62,7 @@ static int generate_common_file(mmfile_t *res, mmfile_t *f1, mmfile_t *f2)
62
xdemitcb_t ecb;
63
64
xpp.flags = XDF_NEED_MINIMAL;
65
+ memset(&xecfg, 0, sizeof(xecfg));
66
xecfg.ctxlen = 3;
67
xecfg.flags = XDL_EMIT_COMMON;
68
ecb.outf = common_outf;
merge-tree.c
+1
-1
@@ -106,8 +106,8 @@ static void show_diff(struct merge_list *entry)
106
xdemitcb_t ecb;
107
108
xpp.flags = XDF_NEED_MINIMAL;
109
+ memset(&xecfg, 0, sizeof(xecfg));
110
xecfg.ctxlen = 3;
110
- xecfg.flags = 0;
111
ecb.outf = show_outf;
112
ecb.priv = NULL;
113