From: Jeff King <peff@peff.net>
To: git@vger.kernel.org
Subject: [PATCH 02/10] diff: drop unused color reset parameters
Date: Thu, 14 Feb 2019 00:48:13 -0500 [thread overview]
Message-ID: <20190214054813.GB20578@sigill.intra.peff.net> (raw)
In-Reply-To: <20190214054736.GA20091@sigill.intra.peff.net>
Several of the emit_* functions take a "reset" color parameter, but
never actually look at it (instead, they call into emit_diff_symbol,
which handles the colors itself). Let's drop these unused parameters.
Note that emit_line() does still take a color/reset pair, and actually
uses it. It cannot be refactored to match these other functions because
it's the thing that emit_diff_symbol eventually calls into (i.e., it
does not by itself know which colors to use, and must be told by the
caller).
Signed-off-by: Jeff King <peff@peff.net>
---
diff.c | 21 ++++++++-------------
1 file changed, 8 insertions(+), 13 deletions(-)
diff --git a/diff.c b/diff.c
index 3e7d11fb70..de45bbd76e 100644
--- a/diff.c
+++ b/diff.c
@@ -1613,8 +1613,7 @@ static int new_blank_line_at_eof(struct emit_callback *ecbdata, const char *line
return ws_blank_line(line, len, ecbdata->ws_rule);
}
-static void emit_add_line(const char *reset,
- struct emit_callback *ecbdata,
+static void emit_add_line(struct emit_callback *ecbdata,
const char *line, int len)
{
unsigned flags = WSEH_NEW | ecbdata->ws_rule;
@@ -1624,16 +1623,14 @@ static void emit_add_line(const char *reset,
emit_diff_symbol(ecbdata->opt, DIFF_SYMBOL_PLUS, line, len, flags);
}
-static void emit_del_line(const char *reset,
- struct emit_callback *ecbdata,
+static void emit_del_line(struct emit_callback *ecbdata,
const char *line, int len)
{
unsigned flags = WSEH_OLD | ecbdata->ws_rule;
emit_diff_symbol(ecbdata->opt, DIFF_SYMBOL_MINUS, line, len, flags);
}
-static void emit_context_line(const char *reset,
- struct emit_callback *ecbdata,
+static void emit_context_line(struct emit_callback *ecbdata,
const char *line, int len)
{
unsigned flags = WSEH_CONTEXT | ecbdata->ws_rule;
@@ -1742,7 +1739,6 @@ static void emit_rewrite_lines(struct emit_callback *ecb,
int prefix, const char *data, int size)
{
const char *endp = NULL;
- const char *reset = diff_get_color(ecb->color_diff, DIFF_RESET);
while (0 < size) {
int len;
@@ -1751,10 +1747,10 @@ static void emit_rewrite_lines(struct emit_callback *ecb,
len = endp ? (endp - data + 1) : size;
if (prefix != '+') {
ecb->lno_in_preimage++;
- emit_del_line(reset, ecb, data, len);
+ emit_del_line(ecb, data, len);
} else {
ecb->lno_in_postimage++;
- emit_add_line(reset, ecb, data, len);
+ emit_add_line(ecb, data, len);
}
size -= len;
data += len;
@@ -2325,7 +2321,6 @@ static void find_lno(const char *line, struct emit_callback *ecbdata)
static void fn_out_consume(void *priv, char *line, unsigned long len)
{
struct emit_callback *ecbdata = priv;
- const char *reset = diff_get_color(ecbdata->color_diff, DIFF_RESET);
struct diff_options *o = ecbdata->opt;
o->found_changes = 1;
@@ -2392,16 +2387,16 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
switch (line[0]) {
case '+':
ecbdata->lno_in_postimage++;
- emit_add_line(reset, ecbdata, line + 1, len - 1);
+ emit_add_line(ecbdata, line + 1, len - 1);
break;
case '-':
ecbdata->lno_in_preimage++;
- emit_del_line(reset, ecbdata, line + 1, len - 1);
+ emit_del_line(ecbdata, line + 1, len - 1);
break;
case ' ':
ecbdata->lno_in_postimage++;
ecbdata->lno_in_preimage++;
- emit_context_line(reset, ecbdata, line + 1, len - 1);
+ emit_context_line(ecbdata, line + 1, len - 1);
break;
default:
/* incomplete line at the end */
--
2.21.0.rc1.567.g648f076c3f
next prev parent reply other threads:[~2019-02-14 5:48 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-14 5:47 [PATCH 0/10] dropping more unused function parameters Jeff King
2019-02-14 5:48 ` [PATCH 01/10] diff: drop options parameter from diffcore_fix_diff_index() Jeff King
2019-02-14 5:48 ` Jeff King [this message]
2019-02-14 5:48 ` [PATCH 03/10] diff: drop unused emit data parameter from sane_truncate_line() Jeff King
2019-02-14 5:49 ` [PATCH 04/10] diff: drop complete_rewrite parameter from run_external_diff() Jeff King
2019-02-14 5:50 ` [PATCH 05/10] merge-recursive: drop several unused parameters Jeff King
2019-02-14 5:50 ` [PATCH 06/10] pack-objects: drop unused parameter from oe_map_new_pack() Jeff King
2019-02-14 5:50 ` [PATCH 07/10] files-backend: drop refs parameter from split_symref_update() Jeff King
2019-02-14 5:50 ` [PATCH 08/10] ref-filter: drop unused buf/sz pairs Jeff King
2019-02-14 5:50 ` [PATCH 09/10] ref-filter: drop unused "obj" parameters Jeff King
2019-02-14 5:51 ` [PATCH 10/10] ref-filter: drop unused "sz" parameters Jeff King
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=20190214054813.GB20578@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
/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).