* [PATCH 1/2] Future-proof source for changes in xdemitconf_t
@ 2007-07-04 18:05 Johannes Schindelin
0 siblings, 0 replies; 3+ messages in thread
From: Johannes Schindelin @ 2007-07-04 18:05 UTC (permalink / raw)
To: git, gitster
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.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
builtin-blame.c | 2 +-
builtin-rerere.c | 2 +-
combine-diff.c | 3 +--
diff.c | 16 ++++++----------
merge-file.c | 1 +
merge-tree.c | 2 +-
6 files changed, 11 insertions(+), 15 deletions(-)
diff --git a/builtin-blame.c b/builtin-blame.c
index da23a6f..0519339 100644
--- a/builtin-blame.c
+++ b/builtin-blame.c
@@ -518,8 +518,8 @@ static struct patch *compare_buffer(mmfile_t *file_p, mmfile_t *file_o,
xdemitcb_t ecb;
xpp.flags = xdl_opts;
+ memset(&xecfg, 0, sizeof(xecfg));
xecfg.ctxlen = context;
- xecfg.flags = 0;
ecb.outf = xdiff_outf;
ecb.priv = &state;
memset(&state, 0, sizeof(state));
diff --git a/builtin-rerere.c b/builtin-rerere.c
index 29fb075..01f3848 100644
--- a/builtin-rerere.c
+++ b/builtin-rerere.c
@@ -282,8 +282,8 @@ static int diff_two(const char *file1, const char *label1,
printf("--- a/%s\n+++ b/%s\n", label1, label2);
fflush(stdout);
xpp.flags = XDF_NEED_MINIMAL;
+ memset(&xecfg, 0, sizeof(xecfg));
xecfg.ctxlen = 3;
- xecfg.flags = 0;
ecb.outf = outf;
xdl_diff(&minus, &plus, &xpp, &xecfg, &ecb);
diff --git a/combine-diff.c b/combine-diff.c
index ea3ca5f..ef62234 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -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.size = sz;
xpp.flags = XDF_NEED_MINIMAL;
- xecfg.ctxlen = 0;
- xecfg.flags = 0;
+ memset(&xecfg, 0, sizeof(xecfg));
ecb.outf = xdiff_outf;
ecb.priv = &state;
memset(&state, 0, sizeof(state));
diff --git a/diff.c b/diff.c
index 1958970..bea0163 100644
--- a/diff.c
+++ b/diff.c
@@ -19,6 +19,7 @@
static int diff_detect_rename_default;
static int diff_rename_limit_default = -1;
static int diff_use_color_default;
+static xdemitconf_t default_xecfg;
static char diff_colors[][COLOR_MAXLEN] = {
"\033[m", /* reset */
@@ -385,7 +386,7 @@ static void fn_out_diff_words_aux(void *priv, char *line, unsigned long len)
static void diff_words_show(struct diff_words_data *diff_words)
{
xpparam_t xpp;
- xdemitconf_t xecfg;
+ xdemitconf_t xecfg = default_xecfg;
xdemitcb_t ecb;
mmfile_t minus, plus;
int i;
@@ -408,7 +409,6 @@ static void diff_words_show(struct diff_words_data *diff_words)
xpp.flags = XDF_NEED_MINIMAL;
xecfg.ctxlen = diff_words->minus.alloc + diff_words->plus.alloc;
- xecfg.flags = 0;
ecb.outf = xdiff_outf;
ecb.priv = diff_words;
diff_words->xm.consume = fn_out_diff_words_aux;
@@ -1198,7 +1198,7 @@ static void builtin_diff(const char *name_a,
/* Crazy xdl interfaces.. */
const char *diffopts = getenv("GIT_DIFF_OPTS");
xpparam_t xpp;
- xdemitconf_t xecfg;
+ xdemitconf_t xecfg = default_xecfg;
xdemitcb_t ecb;
struct emit_callback ecbdata;
@@ -1267,12 +1267,10 @@ static void builtin_diffstat(const char *name_a, const char *name_b,
} else {
/* Crazy xdl interfaces.. */
xpparam_t xpp;
- xdemitconf_t xecfg;
+ xdemitconf_t xecfg = default_xecfg;
xdemitcb_t ecb;
xpp.flags = XDF_NEED_MINIMAL | o->xdl_opts;
- xecfg.ctxlen = 0;
- xecfg.flags = 0;
ecb.outf = xdiff_outf;
ecb.priv = diffstat;
xdl_diff(&mf1, &mf2, &xpp, &xecfg, &ecb);
@@ -1307,12 +1305,10 @@ static void builtin_checkdiff(const char *name_a, const char *name_b,
else {
/* Crazy xdl interfaces.. */
xpparam_t xpp;
- xdemitconf_t xecfg;
+ xdemitconf_t xecfg = default_xecfg;
xdemitcb_t ecb;
xpp.flags = XDF_NEED_MINIMAL;
- xecfg.ctxlen = 0;
- xecfg.flags = 0;
ecb.outf = xdiff_outf;
ecb.priv = &data;
xdl_diff(&mf1, &mf2, &xpp, &xecfg, &ecb);
@@ -2758,7 +2754,7 @@ static int diff_get_patch_id(struct diff_options *options, unsigned char *sha1)
for (i = 0; i < q->nr; i++) {
xpparam_t xpp;
- xdemitconf_t xecfg;
+ xdemitconf_t xecfg = default_xecfg;
xdemitcb_t ecb;
mmfile_t mf1, mf2;
struct diff_filepair *p = q->queue[i];
diff --git a/merge-file.c b/merge-file.c
index 748d15c..1e031ea 100644
--- a/merge-file.c
+++ b/merge-file.c
@@ -62,6 +62,7 @@ static int generate_common_file(mmfile_t *res, mmfile_t *f1, mmfile_t *f2)
xdemitcb_t ecb;
xpp.flags = XDF_NEED_MINIMAL;
+ memset(&xecfg, 0, sizeof(xecfg));
xecfg.ctxlen = 3;
xecfg.flags = XDL_EMIT_COMMON;
ecb.outf = common_outf;
diff --git a/merge-tree.c b/merge-tree.c
index 3b8d9e6..7d4f628 100644
--- a/merge-tree.c
+++ b/merge-tree.c
@@ -106,8 +106,8 @@ static void show_diff(struct merge_list *entry)
xdemitcb_t ecb;
xpp.flags = XDF_NEED_MINIMAL;
+ memset(&xecfg, 0, sizeof(xecfg));
xecfg.ctxlen = 3;
- xecfg.flags = 0;
ecb.outf = show_outf;
ecb.priv = NULL;
--
1.5.3.rc0.804.g7068
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 1/2] Future-proof source for changes in xdemitconf_t
2007-07-05 5:00 ` Junio C Hamano
@ 2007-07-05 5:02 ` Junio C Hamano
2007-07-05 11:01 ` Johannes Schindelin
0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2007-07-05 5:02 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Johannes Schindelin, git
From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Date: Wed, 4 Jul 2007 19:05:46 +0100
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>
---
builtin-blame.c | 2 +-
builtin-rerere.c | 2 +-
combine-diff.c | 3 +--
diff.c | 10 +++++-----
merge-file.c | 1 +
merge-tree.c | 2 +-
6 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/builtin-blame.c b/builtin-blame.c
index da23a6f..0519339 100644
--- a/builtin-blame.c
+++ b/builtin-blame.c
@@ -518,8 +518,8 @@ static struct patch *compare_buffer(mmfile_t *file_p, mmfile_t *file_o,
xdemitcb_t ecb;
xpp.flags = xdl_opts;
+ memset(&xecfg, 0, sizeof(xecfg));
xecfg.ctxlen = context;
- xecfg.flags = 0;
ecb.outf = xdiff_outf;
ecb.priv = &state;
memset(&state, 0, sizeof(state));
diff --git a/builtin-rerere.c b/builtin-rerere.c
index 29fb075..01f3848 100644
--- a/builtin-rerere.c
+++ b/builtin-rerere.c
@@ -282,8 +282,8 @@ static int diff_two(const char *file1, const char *label1,
printf("--- a/%s\n+++ b/%s\n", label1, label2);
fflush(stdout);
xpp.flags = XDF_NEED_MINIMAL;
+ memset(&xecfg, 0, sizeof(xecfg));
xecfg.ctxlen = 3;
- xecfg.flags = 0;
ecb.outf = outf;
xdl_diff(&minus, &plus, &xpp, &xecfg, &ecb);
diff --git a/combine-diff.c b/combine-diff.c
index ea3ca5f..ef62234 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -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.size = sz;
xpp.flags = XDF_NEED_MINIMAL;
- xecfg.ctxlen = 0;
- xecfg.flags = 0;
+ memset(&xecfg, 0, sizeof(xecfg));
ecb.outf = xdiff_outf;
ecb.priv = &state;
memset(&state, 0, sizeof(state));
diff --git a/diff.c b/diff.c
index 1958970..552f7c0 100644
--- a/diff.c
+++ b/diff.c
@@ -390,6 +390,7 @@ static void diff_words_show(struct diff_words_data *diff_words)
mmfile_t minus, plus;
int i;
+ memset(&xecfg, 0, sizeof(xecfg));
minus.size = diff_words->minus.text.size;
minus.ptr = xmalloc(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;
xecfg.ctxlen = diff_words->minus.alloc + diff_words->plus.alloc;
- xecfg.flags = 0;
ecb.outf = xdiff_outf;
ecb.priv = diff_words;
diff_words->xm.consume = fn_out_diff_words_aux;
@@ -1202,6 +1202,7 @@ static void builtin_diff(const char *name_a,
xdemitcb_t ecb;
struct emit_callback ecbdata;
+ memset(&xecfg, 0, sizeof(xecfg));
memset(&ecbdata, 0, sizeof(ecbdata));
ecbdata.label_path = lbl;
ecbdata.color_diff = o->color_diff;
@@ -1270,9 +1271,8 @@ static void builtin_diffstat(const char *name_a, const char *name_b,
xdemitconf_t xecfg;
xdemitcb_t ecb;
+ memset(&xecfg, 0, sizeof(xecfg));
xpp.flags = XDF_NEED_MINIMAL | o->xdl_opts;
- xecfg.ctxlen = 0;
- xecfg.flags = 0;
ecb.outf = xdiff_outf;
ecb.priv = diffstat;
xdl_diff(&mf1, &mf2, &xpp, &xecfg, &ecb);
@@ -1310,9 +1310,8 @@ static void builtin_checkdiff(const char *name_a, const char *name_b,
xdemitconf_t xecfg;
xdemitcb_t ecb;
+ memset(&xecfg, 0, sizeof(xecfg));
xpp.flags = XDF_NEED_MINIMAL;
- xecfg.ctxlen = 0;
- xecfg.flags = 0;
ecb.outf = xdiff_outf;
ecb.priv = &data;
xdl_diff(&mf1, &mf2, &xpp, &xecfg, &ecb);
@@ -2764,6 +2763,7 @@ static int diff_get_patch_id(struct diff_options *options, unsigned char *sha1)
struct diff_filepair *p = q->queue[i];
int len1, len2;
+ memset(&xecfg, 0, sizeof(xecfg));
if (p->status == 0)
return error("internal diff status error");
if (p->status == DIFF_STATUS_UNKNOWN)
diff --git a/merge-file.c b/merge-file.c
index 748d15c..1e031ea 100644
--- a/merge-file.c
+++ b/merge-file.c
@@ -62,6 +62,7 @@ static int generate_common_file(mmfile_t *res, mmfile_t *f1, mmfile_t *f2)
xdemitcb_t ecb;
xpp.flags = XDF_NEED_MINIMAL;
+ memset(&xecfg, 0, sizeof(xecfg));
xecfg.ctxlen = 3;
xecfg.flags = XDL_EMIT_COMMON;
ecb.outf = common_outf;
diff --git a/merge-tree.c b/merge-tree.c
index 3b8d9e6..7d4f628 100644
--- a/merge-tree.c
+++ b/merge-tree.c
@@ -106,8 +106,8 @@ static void show_diff(struct merge_list *entry)
xdemitcb_t ecb;
xpp.flags = XDF_NEED_MINIMAL;
+ memset(&xecfg, 0, sizeof(xecfg));
xecfg.ctxlen = 3;
- xecfg.flags = 0;
ecb.outf = show_outf;
ecb.priv = NULL;
--
1.5.3.rc0.818.ga2b52
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] Future-proof source for changes in xdemitconf_t
2007-07-05 5:02 ` [PATCH 1/2] Future-proof source for changes in xdemitconf_t Junio C Hamano
@ 2007-07-05 11:01 ` Johannes Schindelin
0 siblings, 0 replies; 3+ messages in thread
From: Johannes Schindelin @ 2007-07-05 11:01 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
Hi,
On Wed, 4 Jul 2007, Junio C Hamano wrote:
> [jc: minimally fixed by getting rid of a new global]
Funny. This is identical to my first version of that patch ;-)
Ciao,
Dscho
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-07-05 11:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-04 18:05 [PATCH 1/2] Future-proof source for changes in xdemitconf_t Johannes Schindelin
-- strict thread matches above, loose matches on Subject: below --
2007-07-04 18:06 [PATCH 2/2] diff: add custom regular expressions for function names Johannes Schindelin
2007-07-04 18:41 ` Linus Torvalds
2007-07-04 20:44 ` Junio C Hamano
2007-07-05 5:00 ` Junio C Hamano
2007-07-05 5:02 ` [PATCH 1/2] Future-proof source for changes in xdemitconf_t Junio C Hamano
2007-07-05 11:01 ` Johannes Schindelin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).