{"thread":{"id":"22527","subject":"Showing whitespace on minus lines of diff ouput","startedAt":"2010-02-05T01:47:52Z","lastAt":"2010-02-05T06:17:06Z","messageCount":7,"participants":["Jay Soffian","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"133655","messageId":"76718491002041747t327bf2f5l85e095244f6ee1ed@mail.gmail.com","threadId":"22527","inReplyTo":null,"subject":"Showing whitespace on minus lines of diff ouput","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2010-02-05T01:47:52Z","receivedAt":"2010-02-05T01:47:52Z","isPatch":false,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"The colored diff output is quite helpful to show introductions of whitespace.\n\nHowever, if whitespace has been removed, it's impossible to see in the\ndiff output since whitespace is colorized on '+' lines, but not '-'\nlines.\n\nI'm looking at diff.c, but wow. Can someone more familiar with this\nfile point me toward how I'd make a patch to colorize whitespace on\n'-' lines as well?\n\nThanks,\n\nj.\n"},{"id":"133656","messageId":"76718491002041808r6fcbf88egd1e9ce4927eb36c0@mail.gmail.com","threadId":"22527","inReplyTo":"76718491002041747t327bf2f5l85e095244f6ee1ed@mail.gmail.com","subject":"Re: Showing whitespace on minus lines of diff ouput","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2010-02-05T02:08:34Z","receivedAt":"2010-02-05T02:08:34Z","isPatch":false,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"On Thu, Feb 4, 2010 at 8:47 PM, Jay Soffian <jaysoffian@gmail.com> wrote:\n> I'm looking at diff.c, but wow. Can someone more familiar with this\n> file point me toward how I'd make a patch to colorize whitespace on\n> '-' lines as well?\n\nAh, got it. I think. Patch shortly. :-)\n\nj.\n"},{"id":"133657","messageId":"76718491002041854t445f0a33rf4ffe5158b9f7214@mail.gmail.com","threadId":"22527","inReplyTo":"76718491002041808r6fcbf88egd1e9ce4927eb36c0@mail.gmail.com","subject":"Re: Showing whitespace on minus lines of diff ouput","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2010-02-05T02:54:38Z","receivedAt":"2010-02-05T02:54:38Z","isPatch":false,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"On Thu, Feb 4, 2010 at 9:08 PM, Jay Soffian <jaysoffian@gmail.com> wrote:\n> Ah, got it. I think. Patch shortly. :-)\n\nBah, still need help. Here's what I tried (apologizes for the gmail\nmunging of long lines):\n\ndiff --git a/diff.c b/diff.c\nindex 381cc8d..17133cd 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -331,6 +331,23 @@ static int new_blank_line_at_eof(struct\nemit_callback *ecbdata, const char *line\n \treturn ws_blank_line(line, len, ecbdata->ws_rule);\n }\n\n+static void emit_sub_line(const char *reset,\n+\t\t\t  struct emit_callback *ecbdata,\n+\t\t\t  const char *line, int len)\n+{\n+\tconst char *ws = diff_get_color(ecbdata->color_diff, DIFF_WHITESPACE);\n+\tconst char *set = diff_get_color(ecbdata->color_diff, DIFF_FILE_OLD);\n+\n+\tif (!*ws)\n+\t\temit_line_0(ecbdata->file, set, reset, '-', line, len);\n+\telse {\n+\t\t/* Emit just the prefix, then the rest. */\n+\t\temit_line_0(ecbdata->file, set, reset, '-', \"\", 0);\n+\t\tws_check_emit(line, len, ecbdata->ws_rule,\n+\t\t\t      ecbdata->file, set, reset, ws);\n+\t}\n+}\n+\n static void emit_add_line(const char *reset,\n \t\t\t  struct emit_callback *ecbdata,\n \t\t\t  const char *line, int len)\n@@ -434,7 +451,6 @@ static void emit_rewrite_lines(struct emit_callback *ecb,\n {\n \tconst char *endp = NULL;\n \tstatic const char *nneof = \" No newline at end of file\\n\";\n-\tconst char *old = diff_get_color(ecb->color_diff, DIFF_FILE_OLD);\n \tconst char *reset = diff_get_color(ecb->color_diff, DIFF_RESET);\n\n \twhile (0 < size) {\n@@ -444,8 +460,7 @@ static void emit_rewrite_lines(struct emit_callback *ecb,\n \t\tlen = endp ? (endp - data + 1) : size;\n \t\tif (prefix != '+') {\n \t\t\tecb->lno_in_preimage++;\n-\t\t\temit_line_0(ecb->file, old, reset, '-',\n-\t\t\t\t    data, len);\n+\t\t\temit_sub_line(reset, ecb, data, len);\n \t\t} else {\n \t\t\tecb->lno_in_postimage++;\n \t\t\temit_add_line(reset, ecb, data, len);\n@@ -862,9 +877,12 @@ static void fn_out_consume(void *priv, char\n*line, unsigned long len)\n \t\t\tdiff_get_color(ecbdata->color_diff,\n \t\t\t\t       line[0] == '-' ? DIFF_FILE_OLD : DIFF_PLAIN);\n \t\tecbdata->lno_in_preimage++;\n-\t\tif (line[0] == ' ')\n+\t\tif (line[0] == ' ') {\n \t\t\tecbdata->lno_in_postimage++;\n-\t\temit_line(ecbdata->file, color, reset, line, len);\n+\t\t\temit_line(ecbdata->file, color, reset, line, len);\n+\t\t} else {\n+\t\t\temit_sub_line(reset, ecbdata, line + 1, len - 1);\n+\t\t}\n \t} else {\n \t\tecbdata->lno_in_postimage++;\n \t\temit_add_line(reset, ecbdata, line + 1, len - 1);\n\n\nBut for reasons I don't understand this screws up some of the diff\ntest cases. It's emitting \"index\" lines where it shouldn't, and \"- No\nnewline at end of file\" instead of \"\\ No newline at end of file\".\n\nI guess something is post-processing the output of the emit functions\nand doesn't like the change?\n\nHelp appreciated. :-)\n\nj.\n"},{"id":"133662","messageId":"7veil0o02z.fsf@alter.siamese.dyndns.org","threadId":"22527","inReplyTo":"76718491002041747t327bf2f5l85e095244f6ee1ed@mail.gmail.com","subject":"Re: Showing whitespace on minus lines of diff ouput","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-02-05T03:03:48Z","receivedAt":"2010-02-05T03:03:48Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jay Soffian <jaysoffian@gmail.com> writes:\n\n> The colored diff output is quite helpful to show introductions of whitespace.\n>\n> However, if whitespace has been removed, it's impossible to see in the\n> diff output since whitespace is colorized on '+' lines, but not '-'\n> lines.\n>\n> I'm looking at diff.c, but wow. Can someone more familiar with this\n> file point me toward how I'd make a patch to colorize whitespace on\n> '-' lines as well?\n\nTotally uninterested.  \"diff -R\" would be enough, wouldn't it?\n"},{"id":"133658","messageId":"76718491002041928q11630725gcdae4ff56f1a2b6e@mail.gmail.com","threadId":"22527","inReplyTo":"7veil0o02z.fsf@alter.siamese.dyndns.org","subject":"Re: Showing whitespace on minus lines of diff ouput","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2010-02-05T03:28:15Z","receivedAt":"2010-02-05T03:28:15Z","isPatch":false,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"On Thu, Feb 4, 2010 at 10:03 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Totally uninterested.  \"diff -R\" would be enough, wouldn't it?\n\nDuh, I hadn't thought of that.\n\nj.\n"},{"id":"133670","messageId":"7vr5p0kyp0.fsf@alter.siamese.dyndns.org","threadId":"22527","inReplyTo":"7veil0o02z.fsf@alter.siamese.dyndns.org","subject":"Re: Showing whitespace on minus lines of diff ouput","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-02-05T06:02:03Z","receivedAt":"2010-02-05T06:02:03Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Jay Soffian <jaysoffian@gmail.com> writes:\n>\n>> The colored diff output is quite helpful to show introductions of whitespace.\n>>\n>> However, if whitespace has been removed, it's impossible to see in the\n>> diff output since whitespace is colorized on '+' lines, but not '-'\n>> lines.\n>>\n>> I'm looking at diff.c, but wow. Can someone more familiar with this\n>> file point me toward how I'd make a patch to colorize whitespace on\n>> '-' lines as well?\n>\n> Totally uninterested.  \"diff -R\" would be enough, wouldn't it?\n\nActually the reason I don't like the idea to highlight corrected errors\nwas not just because \"'diff -R' is enough\".\n\nThe coloring of whitespace errors are like compiler warnings, at least to\nme, and giving similar highlighting to corrected ones defeats the purpose\nby making the output more distracting..\n"},{"id":"133668","messageId":"76718491002042217g42e85a70r195cf75e0892dc54@mail.gmail.com","threadId":"22527","inReplyTo":"7vr5p0kyp0.fsf@alter.siamese.dyndns.org","subject":"Re: Showing whitespace on minus lines of diff ouput","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2010-02-05T06:17:06Z","receivedAt":"2010-02-05T06:17:06Z","isPatch":false,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"On Fri, Feb 5, 2010 at 1:02 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> Actually the reason I don't like the idea to highlight corrected errors\n> was not just because \"'diff -R' is enough\".\n>\n> The coloring of whitespace errors are like compiler warnings, at least to\n> me, and giving similar highlighting to corrected ones defeats the purpose\n> by making the output more distracting..\n\nThat makes perfect sense. I didn't think it through very well. :-)\n\nj.\n"}]}