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

[PATCH 3/3] diff: remove dead code

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

When `len < 1`, len has to be 0 or negative, emit_line will then remove the first character and by then `len` would be negative. As this doesn't happen, it is safe to assume it is dead code.

This continues to simplify the code, which was started in b8d9c1a66b (2009-09-03, diff.c: the builtin_diff() deals with only two-file comparison).

Signed-off-by: Stefan Beller <sbeller@google.com>
---
 diff.c | 8 --------
 1 file changed, 8 deletions(-)
diff --git a/diff.c b/diff.c
index 79ad91d..c143019 100644
--- a/diff.c
+++ b/diff.c
@@ -1251,14 +1251,6 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
 		return;
 	}
 
-	if (len < 1) {
-		emit_line(o, reset, reset, line, len);
-		if (ecbdata->diff_words
-		    && ecbdata->diff_words->type == DIFF_WORDS_PORCELAIN)
-			fputs("~\n", o->file);
-		return;
-	}
-
 	if (ecbdata->diff_words) {
 		if (line[0] == '-') {
 			diff_words_append(line, len,
-- 
2.10.0.2.g0676c79.dirty
Previous: Junio C HamanoNext: Junio C Hamano
Message 7 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.