git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/2] diff: omit found pointer from emit_callback

From
Stefan Beller <sbeller@google.com>
Date
Sep 7, 2016, 23:36 UTC
Message-ID
<20160907233648.5162-3-sbeller@google.com>
In-Reply-To
<20160907233648.5162-1-sbeller@google.com>

We keep the actual data in the diff options, which are just as accessible. Remove the pointer stored in struct emit_callback for readability.

Signed-off-by: Stefan Beller <sbeller@google.com>
---
 diff.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
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;
 };
 
@@ -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;
 
 	if (ecbdata->label_path[0]) {
 		const char *name_a_tab, *name_b_tab;
@@ -2437,7 +2435,6 @@ static void builtin_diff(const char *name_a,
 		memset(&ecbdata, 0, sizeof(ecbdata));
 		ecbdata.label_path = lbl;
 		ecbdata.color_diff = want_color(o->use_color);
-		ecbdata.found_changesp = &o->found_changes;
 		ecbdata.ws_rule = whitespace_rule(name_b);
 		if (ecbdata.ws_rule & WS_BLANK_AT_EOF)
 			check_blank_at_eof(&mf1, &mf2, &ecbdata);
-- 
2.10.0.2.g0676c79.dirty
Previous: Jacob KellerNext: Stefan Beller
Message 4 of 9 in “preparatory diff improvements for moved color detection”
  1. 0/3 preparatory diff improvements for moved color detectionStefan Beller, Sep 7, 2016
  2. 1/3 diff.c: use diff_options directlyStefan Beller, Sep 7, 2016
  3. Jacob KellerSep 8, 2016
  4. 1/2 diff: omit found pointer from emit_callbackStefan Beller, Sep 7, 2016
  5. 2/3 diff: omit found pointer from emit_callbackStefan Beller, Sep 7, 2016
  6. Junio C HamanoSep 8, 2016
  7. 3/3 diff: remove dead codeStefan Beller, Sep 7, 2016
  8. Junio C HamanoSep 8, 2016
  9. 2/2 diff: remove dead codeStefan Beller, Sep 7, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.