From: Junio C Hamano <gitster@pobox.com>
To: Stefan Beller <sbeller@google.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 2/3] diff: omit found pointer from emit_callback
Date: Thu, 08 Sep 2016 13:53:29 -0700 [thread overview]
Message-ID: <xmqqpooef706.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <20160907233648.5162-4-sbeller@google.com> (Stefan Beller's message of "Wed, 7 Sep 2016 16:36:46 -0700")
Stefan Beller <sbeller@google.com> writes:
> diff --git a/diff.c b/diff.c
> index 4a6501c..79ad91d 100644
> --- a/diff.c
> +++ b/diff.c
> @@ -354,7 +354,6 @@ struct emit_callback {
> const char **label_path;
> struct diff_words_data *diff_words;
> struct diff_options *opt;
> - int *found_changesp;
> struct strbuf *header;
> };
I briefly wondered if we have some callsites that do not want
o->found_changes to be modified (hence pointing this field at
elsewhere), but the fact that you can _remove_ this field means that
there is no such use case, which is good.
> @@ -722,7 +721,6 @@ static void emit_rewrite_diff(const char *name_a,
>
> memset(&ecbdata, 0, sizeof(ecbdata));
> ecbdata.color_diff = want_color(o->use_color);
> - ecbdata.found_changesp = &o->found_changes;
> ecbdata.ws_rule = whitespace_rule(name_b);
> ecbdata.opt = o;
> if (ecbdata.ws_rule & WS_BLANK_AT_EOF) {
> @@ -1215,13 +1213,13 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
> const char *reset = diff_get_color(ecbdata->color_diff, DIFF_RESET);
> struct diff_options *o = ecbdata->opt;
> const char *line_prefix = diff_line_prefix(o);
> + o->found_changes = 1;
>
> if (ecbdata->header) {
> fprintf(o->file, "%s", ecbdata->header->buf);
> strbuf_reset(ecbdata->header);
> ecbdata->header = NULL;
> }
> - *(ecbdata->found_changesp) = 1;
Is there a good reason to move the assignment up? "The fact that
this function was called even once means we found some change" is
probably a good argument, but then I'd prefer to have a blank before
it to separate it (the first statement) from the block of decls.
No need to resend. Thanks.
next prev parent reply other threads:[~2016-09-08 20:53 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-07 23:36 [PATCH 0/3] preparatory diff improvements for moved color detection Stefan Beller
2016-09-07 23:36 ` [PATCH 1/3] diff.c: use diff_options directly Stefan Beller
2016-09-08 5:33 ` Jacob Keller
2016-09-07 23:36 ` [PATCH 1/2] diff: omit found pointer from emit_callback Stefan Beller
2016-09-07 23:36 ` [PATCH 2/3] " Stefan Beller
2016-09-08 20:53 ` Junio C Hamano [this message]
2016-09-07 23:36 ` [PATCH 2/2] diff: remove dead code Stefan Beller
2016-09-07 23:36 ` [PATCH 3/3] " Stefan Beller
2016-09-08 21:07 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqpooef706.fsf@gitster.mtv.corp.google.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=sbeller@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).