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

[PATCH 3/7] range-diff: make use of different output indicators

From
Stefan Beller <sbeller@google.com>
Date
Aug 4, 2018, 01:53 UTC
Message-ID
<20180804015317.182683-4-sbeller@google.com>
In-Reply-To
<20180804015317.182683-1-sbeller@google.com>

This change itself only changes the internal communication and should have no visible effect to the user. We instruct the diff code that produces the inner diffs to use X, Y, Z instead of the usual markers for new, old and context lines

Signed-off-by: Stefan Beller <sbeller@google.com>
---
 range-diff.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/range-diff.c b/range-diff.c
index 347b4a79f25..a4ff945427e 100644
--- a/range-diff.c
+++ b/range-diff.c
@@ -38,6 +38,9 @@ static int read_patches(const char *range, struct string_list *list)
 
 	argv_array_pushl(&cp.args, "log", "--no-color", "-p", "--no-merges",
 			"--reverse", "--date-order", "--decorate=no",
+			"--output-indicator-new=X",
+			"--output-indicator-old=Y",
+			"--output-indicator-context=Z",
 			"--no-abbrev-commit", range,
 			NULL);
 	cp.out = -1;
@@ -108,8 +111,18 @@ static int read_patches(const char *range, struct string_list *list)
 			 * we are not interested.
 			 */
 			continue;
-		else
+		else if (line.buf[0] == 'X') {
+			strbuf_addch(&buf, '+');
+			strbuf_add(&buf, line.buf + 1, line.len - 1);
+		} else if (line.buf[0] == 'Y') {
+			strbuf_addch(&buf, '-');
+			strbuf_add(&buf, line.buf + 1, line.len - 1);
+		} else if (line.buf[0] == 'Z') {
+			strbuf_addch(&buf, ' ');
+			strbuf_add(&buf, line.buf + 1, line.len - 1);
+		} else {
 			strbuf_addbuf(&buf, &line);
+		}
 
 		strbuf_addch(&buf, '\n');
 		util->diffsize++;
-- 
2.18.0.597.ga71716f1ad-goog
Previous: Stefan BellerNext: Stefan Beller
Message 4 of 13 in “improve range-diffs coloring and [RFC] move detection”
  1. 0/7 improve range-diffs coloring and [RFC] move detectionStefan Beller, Aug 4, 2018
  2. 1/7 diff.c: emit_line_0 to take string instead of first signStefan Beller, Aug 4, 2018
  3. 2/7 diff.c: add --output-indicator-{new, old, context}Stefan Beller, Aug 4, 2018
  4. 3/7 range-diff: make use of different output indicatorsStefan Beller, Aug 4, 2018
  5. 4/7 range-diff: indent special lines as contextStefan Beller, Aug 4, 2018
  6. 5/7 diff.c: rename color_moved to markup_movedStefan Beller, Aug 4, 2018
  7. 6/7 diff.c: factor determine_line_color out of emit_diff_symbol_from_structStefan Beller, Aug 4, 2018
  8. 7/7 diff/am: enhance diff format to use */~ for moved linesStefan Beller, Aug 4, 2018
  9. Junio C HamanoAug 4, 2018
  10. Stefan BellerAug 6, 2018
  11. Junio C HamanoAug 4, 2018
  12. Stefan BellerAug 6, 2018
  13. Junio C HamanoAug 6, 2018

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.