From: Jacob Keller <jacob.keller@gmail.com>
To: Stefan Beller <sbeller@google.com>
Cc: Junio C Hamano <gitster@pobox.com>,
Git mailing list <git@vger.kernel.org>
Subject: Re: [PATCH 1/3] diff.c: use diff_options directly
Date: Wed, 7 Sep 2016 22:33:52 -0700 [thread overview]
Message-ID: <CA+P7+xrdtwAQkmHGkL37rZMJLWAn1ezAophn+QASz354eL8MqQ@mail.gmail.com> (raw)
In-Reply-To: <20160907233648.5162-2-sbeller@google.com>
On Wed, Sep 7, 2016 at 4:36 PM, Stefan Beller <sbeller@google.com> wrote:
> The value of `ecbdata->opt` is accessible via the short variable `o`
> already, so let's use that instead.
>
> Signed-off-by: Stefan Beller <sbeller@google.com>
Seems reasonable.
> ---
> diff.c | 21 ++++++++++-----------
> 1 file changed, 10 insertions(+), 11 deletions(-)
>
> diff --git a/diff.c b/diff.c
> index 534c12e..4a6501c 100644
> --- a/diff.c
> +++ b/diff.c
> @@ -1217,7 +1217,7 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
> const char *line_prefix = diff_line_prefix(o);
>
> if (ecbdata->header) {
> - fprintf(ecbdata->opt->file, "%s", ecbdata->header->buf);
> + fprintf(o->file, "%s", ecbdata->header->buf);
> strbuf_reset(ecbdata->header);
> ecbdata->header = NULL;
> }
> @@ -1229,9 +1229,9 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
> name_a_tab = strchr(ecbdata->label_path[0], ' ') ? "\t" : "";
> name_b_tab = strchr(ecbdata->label_path[1], ' ') ? "\t" : "";
>
> - fprintf(ecbdata->opt->file, "%s%s--- %s%s%s\n",
> + fprintf(o->file, "%s%s--- %s%s%s\n",
> line_prefix, meta, ecbdata->label_path[0], reset, name_a_tab);
> - fprintf(ecbdata->opt->file, "%s%s+++ %s%s%s\n",
> + fprintf(o->file, "%s%s+++ %s%s%s\n",
> line_prefix, meta, ecbdata->label_path[1], reset, name_b_tab);
> ecbdata->label_path[0] = ecbdata->label_path[1] = NULL;
> }
> @@ -1249,15 +1249,15 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
> find_lno(line, ecbdata);
> emit_hunk_header(ecbdata, line, len);
> if (line[len-1] != '\n')
> - putc('\n', ecbdata->opt->file);
> + putc('\n', o->file);
> return;
> }
>
> if (len < 1) {
> - emit_line(ecbdata->opt, reset, reset, line, len);
> + emit_line(o, reset, reset, line, len);
> if (ecbdata->diff_words
> && ecbdata->diff_words->type == DIFF_WORDS_PORCELAIN)
> - fputs("~\n", ecbdata->opt->file);
> + fputs("~\n", o->file);
> return;
> }
>
> @@ -1282,8 +1282,8 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
> }
> diff_words_flush(ecbdata);
> if (ecbdata->diff_words->type == DIFF_WORDS_PORCELAIN) {
> - emit_line(ecbdata->opt, context, reset, line, len);
> - fputs("~\n", ecbdata->opt->file);
> + emit_line(o, context, reset, line, len);
> + fputs("~\n", o->file);
> } else {
> /*
> * Skip the prefix character, if any. With
> @@ -1294,7 +1294,7 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
> line++;
> len--;
> }
> - emit_line(ecbdata->opt, context, reset, line, len);
> + emit_line(o, context, reset, line, len);
> }
> return;
> }
> @@ -1316,8 +1316,7 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
> default:
> /* incomplete line at the end */
> ecbdata->lno_in_preimage++;
> - emit_line(ecbdata->opt,
> - diff_get_color(ecbdata->color_diff, DIFF_CONTEXT),
> + emit_line(o, diff_get_color(ecbdata->color_diff, DIFF_CONTEXT),
> reset, line, len);
> break;
> }
> --
> 2.10.0.2.g0676c79.dirty
>
next prev parent reply other threads:[~2016-09-08 6:32 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 [this message]
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
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=CA+P7+xrdtwAQkmHGkL37rZMJLWAn1ezAophn+QASz354eL8MqQ@mail.gmail.com \
--to=jacob.keller@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--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).