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>
This commit is contained in:
parent
29a3eefde1
commit
30b250104d
@ -518,8 +518,8 @@ static struct patch *compare_buffer(mmfile_t *file_p, mmfile_t *file_o,
|
|||||||
xdemitcb_t ecb;
|
xdemitcb_t ecb;
|
||||||
|
|
||||||
xpp.flags = xdl_opts;
|
xpp.flags = xdl_opts;
|
||||||
|
memset(&xecfg, 0, sizeof(xecfg));
|
||||||
xecfg.ctxlen = context;
|
xecfg.ctxlen = context;
|
||||||
xecfg.flags = 0;
|
|
||||||
ecb.outf = xdiff_outf;
|
ecb.outf = xdiff_outf;
|
||||||
ecb.priv = &state;
|
ecb.priv = &state;
|
||||||
memset(&state, 0, sizeof(state));
|
memset(&state, 0, sizeof(state));
|
||||||
|
@ -282,8 +282,8 @@ static int diff_two(const char *file1, const char *label1,
|
|||||||
printf("--- a/%s\n+++ b/%s\n", label1, label2);
|
printf("--- a/%s\n+++ b/%s\n", label1, label2);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
xpp.flags = XDF_NEED_MINIMAL;
|
xpp.flags = XDF_NEED_MINIMAL;
|
||||||
|
memset(&xecfg, 0, sizeof(xecfg));
|
||||||
xecfg.ctxlen = 3;
|
xecfg.ctxlen = 3;
|
||||||
xecfg.flags = 0;
|
|
||||||
ecb.outf = outf;
|
ecb.outf = outf;
|
||||||
xdl_diff(&minus, &plus, &xpp, &xecfg, &ecb);
|
xdl_diff(&minus, &plus, &xpp, &xecfg, &ecb);
|
||||||
|
|
||||||
|
@ -215,8 +215,7 @@ static void combine_diff(const unsigned char *parent, mmfile_t *result_file,
|
|||||||
parent_file.ptr = grab_blob(parent, &sz);
|
parent_file.ptr = grab_blob(parent, &sz);
|
||||||
parent_file.size = sz;
|
parent_file.size = sz;
|
||||||
xpp.flags = XDF_NEED_MINIMAL;
|
xpp.flags = XDF_NEED_MINIMAL;
|
||||||
xecfg.ctxlen = 0;
|
memset(&xecfg, 0, sizeof(xecfg));
|
||||||
xecfg.flags = 0;
|
|
||||||
ecb.outf = xdiff_outf;
|
ecb.outf = xdiff_outf;
|
||||||
ecb.priv = &state;
|
ecb.priv = &state;
|
||||||
memset(&state, 0, sizeof(state));
|
memset(&state, 0, sizeof(state));
|
||||||
|
10
diff.c
10
diff.c
@ -390,6 +390,7 @@ static void diff_words_show(struct diff_words_data *diff_words)
|
|||||||
mmfile_t minus, plus;
|
mmfile_t minus, plus;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
memset(&xecfg, 0, sizeof(xecfg));
|
||||||
minus.size = diff_words->minus.text.size;
|
minus.size = diff_words->minus.text.size;
|
||||||
minus.ptr = xmalloc(minus.size);
|
minus.ptr = xmalloc(minus.size);
|
||||||
memcpy(minus.ptr, diff_words->minus.text.ptr, minus.size);
|
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)
|
|||||||
|
|
||||||
xpp.flags = XDF_NEED_MINIMAL;
|
xpp.flags = XDF_NEED_MINIMAL;
|
||||||
xecfg.ctxlen = diff_words->minus.alloc + diff_words->plus.alloc;
|
xecfg.ctxlen = diff_words->minus.alloc + diff_words->plus.alloc;
|
||||||
xecfg.flags = 0;
|
|
||||||
ecb.outf = xdiff_outf;
|
ecb.outf = xdiff_outf;
|
||||||
ecb.priv = diff_words;
|
ecb.priv = diff_words;
|
||||||
diff_words->xm.consume = fn_out_diff_words_aux;
|
diff_words->xm.consume = fn_out_diff_words_aux;
|
||||||
@ -1218,6 +1218,7 @@ static void builtin_diff(const char *name_a,
|
|||||||
xdemitcb_t ecb;
|
xdemitcb_t ecb;
|
||||||
struct emit_callback ecbdata;
|
struct emit_callback ecbdata;
|
||||||
|
|
||||||
|
memset(&xecfg, 0, sizeof(xecfg));
|
||||||
memset(&ecbdata, 0, sizeof(ecbdata));
|
memset(&ecbdata, 0, sizeof(ecbdata));
|
||||||
ecbdata.label_path = lbl;
|
ecbdata.label_path = lbl;
|
||||||
ecbdata.color_diff = o->color_diff;
|
ecbdata.color_diff = o->color_diff;
|
||||||
@ -1286,9 +1287,8 @@ static void builtin_diffstat(const char *name_a, const char *name_b,
|
|||||||
xdemitconf_t xecfg;
|
xdemitconf_t xecfg;
|
||||||
xdemitcb_t ecb;
|
xdemitcb_t ecb;
|
||||||
|
|
||||||
|
memset(&xecfg, 0, sizeof(xecfg));
|
||||||
xpp.flags = XDF_NEED_MINIMAL | o->xdl_opts;
|
xpp.flags = XDF_NEED_MINIMAL | o->xdl_opts;
|
||||||
xecfg.ctxlen = 0;
|
|
||||||
xecfg.flags = 0;
|
|
||||||
ecb.outf = xdiff_outf;
|
ecb.outf = xdiff_outf;
|
||||||
ecb.priv = diffstat;
|
ecb.priv = diffstat;
|
||||||
xdl_diff(&mf1, &mf2, &xpp, &xecfg, &ecb);
|
xdl_diff(&mf1, &mf2, &xpp, &xecfg, &ecb);
|
||||||
@ -1326,9 +1326,8 @@ static void builtin_checkdiff(const char *name_a, const char *name_b,
|
|||||||
xdemitconf_t xecfg;
|
xdemitconf_t xecfg;
|
||||||
xdemitcb_t ecb;
|
xdemitcb_t ecb;
|
||||||
|
|
||||||
|
memset(&xecfg, 0, sizeof(xecfg));
|
||||||
xpp.flags = XDF_NEED_MINIMAL;
|
xpp.flags = XDF_NEED_MINIMAL;
|
||||||
xecfg.ctxlen = 0;
|
|
||||||
xecfg.flags = 0;
|
|
||||||
ecb.outf = xdiff_outf;
|
ecb.outf = xdiff_outf;
|
||||||
ecb.priv = &data;
|
ecb.priv = &data;
|
||||||
xdl_diff(&mf1, &mf2, &xpp, &xecfg, &ecb);
|
xdl_diff(&mf1, &mf2, &xpp, &xecfg, &ecb);
|
||||||
@ -2780,6 +2779,7 @@ static int diff_get_patch_id(struct diff_options *options, unsigned char *sha1)
|
|||||||
struct diff_filepair *p = q->queue[i];
|
struct diff_filepair *p = q->queue[i];
|
||||||
int len1, len2;
|
int len1, len2;
|
||||||
|
|
||||||
|
memset(&xecfg, 0, sizeof(xecfg));
|
||||||
if (p->status == 0)
|
if (p->status == 0)
|
||||||
return error("internal diff status error");
|
return error("internal diff status error");
|
||||||
if (p->status == DIFF_STATUS_UNKNOWN)
|
if (p->status == DIFF_STATUS_UNKNOWN)
|
||||||
|
@ -62,6 +62,7 @@ static int generate_common_file(mmfile_t *res, mmfile_t *f1, mmfile_t *f2)
|
|||||||
xdemitcb_t ecb;
|
xdemitcb_t ecb;
|
||||||
|
|
||||||
xpp.flags = XDF_NEED_MINIMAL;
|
xpp.flags = XDF_NEED_MINIMAL;
|
||||||
|
memset(&xecfg, 0, sizeof(xecfg));
|
||||||
xecfg.ctxlen = 3;
|
xecfg.ctxlen = 3;
|
||||||
xecfg.flags = XDL_EMIT_COMMON;
|
xecfg.flags = XDL_EMIT_COMMON;
|
||||||
ecb.outf = common_outf;
|
ecb.outf = common_outf;
|
||||||
|
@ -106,8 +106,8 @@ static void show_diff(struct merge_list *entry)
|
|||||||
xdemitcb_t ecb;
|
xdemitcb_t ecb;
|
||||||
|
|
||||||
xpp.flags = XDF_NEED_MINIMAL;
|
xpp.flags = XDF_NEED_MINIMAL;
|
||||||
|
memset(&xecfg, 0, sizeof(xecfg));
|
||||||
xecfg.ctxlen = 3;
|
xecfg.ctxlen = 3;
|
||||||
xecfg.flags = 0;
|
|
||||||
ecb.outf = show_outf;
|
ecb.outf = show_outf;
|
||||||
ecb.priv = NULL;
|
ecb.priv = NULL;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user