range-diff: make use of different output indicators
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 other markers instead of the usual markers for new, old and context lines. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Stefan Beller committed
Aug 17, 2018 at 13:43 UTC
8d5ccb59def8c1737b3e055a5984eaaa4e881ce9
1 file changed
+19
-1
range-diff.c
+19
-1
@@ -38,6 +38,14 @@ static int read_patches(const char *range, struct string_list *list)
38
39
argv_array_pushl(&cp.args, "log", "--no-color", "-p", "--no-merges",
40
"--reverse", "--date-order", "--decorate=no",
41
+ /*
42
+ * Choose indicators that are not used anywhere
43
+ * else in diffs, but still look reasonable
44
+ * (e.g. will not be confusing when debugging)
45
+ */
46
+ "--output-indicator-new=>",
47
+ "--output-indicator-old=<",
48
+ "--output-indicator-context=#",
49
"--no-abbrev-commit", range,
50
NULL);
51
cp.out = -1;
@@ -108,8 +116,18 @@ static int read_patches(const char *range, struct string_list *list)
116
* we are not interested.
117
*/
118
continue;
111
- else
119
+ else if (line.buf[0] == '>') {
120
+ strbuf_addch(&buf, '+');
121
+ strbuf_add(&buf, line.buf + 1, line.len - 1);
122
+ } else if (line.buf[0] == '<') {
123
+ strbuf_addch(&buf, '-');
124
+ strbuf_add(&buf, line.buf + 1, line.len - 1);
125
+ } else if (line.buf[0] == '#') {
126
+ strbuf_addch(&buf, ' ');
127
+ strbuf_add(&buf, line.buf + 1, line.len - 1);
128
+ } else {
129
strbuf_addbuf(&buf, &line);
130
+ }
131
132
strbuf_addch(&buf, '\n');
133
util->diffsize++;