{"thread":{"id":"8865","subject":"[PATCH 1/2] Future-proof source for changes in xdemitconf_t","startedAt":"2007-07-04T18:05:46Z","lastAt":"2007-07-04T18:05:46Z","messageCount":1,"participants":["Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"46501","messageId":"Pine.LNX.4.64.0707041905090.4071@racer.site","threadId":"8865","inReplyTo":null,"subject":"[PATCH 1/2] Future-proof source for changes in xdemitconf_t","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-07-04T18:05:46Z","receivedAt":"2007-07-04T18:05:46Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nThe instances of xdemitconf_t were initialized member by member.\nInstead, initialize them to all zero, so we do not have\nto update those places each time we introduce a new member.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n builtin-blame.c  |    2 +-\n builtin-rerere.c |    2 +-\n combine-diff.c   |    3 +--\n diff.c           |   16 ++++++----------\n merge-file.c     |    1 +\n merge-tree.c     |    2 +-\n 6 files changed, 11 insertions(+), 15 deletions(-)\n\ndiff --git a/builtin-blame.c b/builtin-blame.c\nindex da23a6f..0519339 100644\n--- a/builtin-blame.c\n+++ b/builtin-blame.c\n@@ -518,8 +518,8 @@ static struct patch *compare_buffer(mmfile_t *file_p, mmfile_t *file_o,\n \txdemitcb_t ecb;\n \n \txpp.flags = xdl_opts;\n+\tmemset(&xecfg, 0, sizeof(xecfg));\n \txecfg.ctxlen = context;\n-\txecfg.flags = 0;\n \tecb.outf = xdiff_outf;\n \tecb.priv = &state;\n \tmemset(&state, 0, sizeof(state));\ndiff --git a/builtin-rerere.c b/builtin-rerere.c\nindex 29fb075..01f3848 100644\n--- a/builtin-rerere.c\n+++ b/builtin-rerere.c\n@@ -282,8 +282,8 @@ static int diff_two(const char *file1, const char *label1,\n \tprintf(\"--- a/%s\\n+++ b/%s\\n\", label1, label2);\n \tfflush(stdout);\n \txpp.flags = XDF_NEED_MINIMAL;\n+\tmemset(&xecfg, 0, sizeof(xecfg));\n \txecfg.ctxlen = 3;\n-\txecfg.flags = 0;\n \tecb.outf = outf;\n \txdl_diff(&minus, &plus, &xpp, &xecfg, &ecb);\n \ndiff --git a/combine-diff.c b/combine-diff.c\nindex ea3ca5f..ef62234 100644\n--- a/combine-diff.c\n+++ b/combine-diff.c\n@@ -215,8 +215,7 @@ static void combine_diff(const unsigned char *parent, mmfile_t *result_file,\n \tparent_file.ptr = grab_blob(parent, &sz);\n \tparent_file.size = sz;\n \txpp.flags = XDF_NEED_MINIMAL;\n-\txecfg.ctxlen = 0;\n-\txecfg.flags = 0;\n+\tmemset(&xecfg, 0, sizeof(xecfg));\n \tecb.outf = xdiff_outf;\n \tecb.priv = &state;\n \tmemset(&state, 0, sizeof(state));\ndiff --git a/diff.c b/diff.c\nindex 1958970..bea0163 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -19,6 +19,7 @@\n static int diff_detect_rename_default;\n static int diff_rename_limit_default = -1;\n static int diff_use_color_default;\n+static xdemitconf_t default_xecfg;\n \n static char diff_colors[][COLOR_MAXLEN] = {\n \t\"\\033[m\",\t/* reset */\n@@ -385,7 +386,7 @@ static void fn_out_diff_words_aux(void *priv, char *line, unsigned long len)\n static void diff_words_show(struct diff_words_data *diff_words)\n {\n \txpparam_t xpp;\n-\txdemitconf_t xecfg;\n+\txdemitconf_t xecfg = default_xecfg;\n \txdemitcb_t ecb;\n \tmmfile_t minus, plus;\n \tint i;\n@@ -408,7 +409,6 @@ static void diff_words_show(struct diff_words_data *diff_words)\n \n \txpp.flags = XDF_NEED_MINIMAL;\n \txecfg.ctxlen = diff_words->minus.alloc + diff_words->plus.alloc;\n-\txecfg.flags = 0;\n \tecb.outf = xdiff_outf;\n \tecb.priv = diff_words;\n \tdiff_words->xm.consume = fn_out_diff_words_aux;\n@@ -1198,7 +1198,7 @@ static void builtin_diff(const char *name_a,\n \t\t/* Crazy xdl interfaces.. */\n \t\tconst char *diffopts = getenv(\"GIT_DIFF_OPTS\");\n \t\txpparam_t xpp;\n-\t\txdemitconf_t xecfg;\n+\t\txdemitconf_t xecfg = default_xecfg;\n \t\txdemitcb_t ecb;\n \t\tstruct emit_callback ecbdata;\n \n@@ -1267,12 +1267,10 @@ static void builtin_diffstat(const char *name_a, const char *name_b,\n \t} else {\n \t\t/* Crazy xdl interfaces.. */\n \t\txpparam_t xpp;\n-\t\txdemitconf_t xecfg;\n+\t\txdemitconf_t xecfg = default_xecfg;\n \t\txdemitcb_t ecb;\n \n \t\txpp.flags = XDF_NEED_MINIMAL | o->xdl_opts;\n-\t\txecfg.ctxlen = 0;\n-\t\txecfg.flags = 0;\n \t\tecb.outf = xdiff_outf;\n \t\tecb.priv = diffstat;\n \t\txdl_diff(&mf1, &mf2, &xpp, &xecfg, &ecb);\n@@ -1307,12 +1305,10 @@ static void builtin_checkdiff(const char *name_a, const char *name_b,\n \telse {\n \t\t/* Crazy xdl interfaces.. */\n \t\txpparam_t xpp;\n-\t\txdemitconf_t xecfg;\n+\t\txdemitconf_t xecfg = default_xecfg;\n \t\txdemitcb_t ecb;\n \n \t\txpp.flags = XDF_NEED_MINIMAL;\n-\t\txecfg.ctxlen = 0;\n-\t\txecfg.flags = 0;\n \t\tecb.outf = xdiff_outf;\n \t\tecb.priv = &data;\n \t\txdl_diff(&mf1, &mf2, &xpp, &xecfg, &ecb);\n@@ -2758,7 +2754,7 @@ static int diff_get_patch_id(struct diff_options *options, unsigned char *sha1)\n \n \tfor (i = 0; i < q->nr; i++) {\n \t\txpparam_t xpp;\n-\t\txdemitconf_t xecfg;\n+\t\txdemitconf_t xecfg = default_xecfg;\n \t\txdemitcb_t ecb;\n \t\tmmfile_t mf1, mf2;\n \t\tstruct diff_filepair *p = q->queue[i];\ndiff --git a/merge-file.c b/merge-file.c\nindex 748d15c..1e031ea 100644\n--- a/merge-file.c\n+++ b/merge-file.c\n@@ -62,6 +62,7 @@ static int generate_common_file(mmfile_t *res, mmfile_t *f1, mmfile_t *f2)\n \txdemitcb_t ecb;\n \n \txpp.flags = XDF_NEED_MINIMAL;\n+\tmemset(&xecfg, 0, sizeof(xecfg));\n \txecfg.ctxlen = 3;\n \txecfg.flags = XDL_EMIT_COMMON;\n \tecb.outf = common_outf;\ndiff --git a/merge-tree.c b/merge-tree.c\nindex 3b8d9e6..7d4f628 100644\n--- a/merge-tree.c\n+++ b/merge-tree.c\n@@ -106,8 +106,8 @@ static void show_diff(struct merge_list *entry)\n \txdemitcb_t ecb;\n \n \txpp.flags = XDF_NEED_MINIMAL;\n+\tmemset(&xecfg, 0, sizeof(xecfg));\n \txecfg.ctxlen = 3;\n-\txecfg.flags = 0;\n \tecb.outf = show_outf;\n \tecb.priv = NULL;\n \n-- \n1.5.3.rc0.804.g7068\n"}]}