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

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

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Aug 13, 2018, 11:51 UTC
Message-ID
<nycvar.QRO.7.76.6.1808131348120.71@tvgsbejvaqbjf.bet>
In-Reply-To
<20180810224923.143625-4-sbeller@google.com>
Hi Stefan,
On Fri, 10 Aug 2018, Stefan Beller wrote:
Show 41 quoted lines
> 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 b6b9abac266..6e4192c8e79 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);
> +		}

My preliminary reading (I sadly lack the time to pull your branch and play with it) suggests that this works, although I have to admit that X/Y/Z would confuse me in 6 months from now, as they do not really read like diff markers but like plain text. I could imagine that '>', '<' and '#' would not impart that confusion on me.

Ciao, Dscho

Show 7 quoted lines
>  
>  		strbuf_addch(&buf, '\n');
>  		util->diffsize++;
> -- 
> 2.18.0.865.gffc8e1a3cd6-goog
> 
> 
Previous: Stefan BellerNext: Stefan Beller
Message 9 of 27 in “Better colors in range-diff!”
  1. 0/4 Better colors in range-diff!Stefan Beller, Aug 10, 2018
  2. 1/4 diff.c: emit_line_0 to take string instead of first signStefan Beller, Aug 10, 2018
  3. Johannes SchindelinAug 13, 2018
  4. Stefan BellerAug 13, 2018
  5. 2/4 diff.c: add --output-indicator-{new, old, context}Stefan Beller, Aug 10, 2018
  6. Johannes SchindelinAug 13, 2018
  7. Stefan BellerAug 13, 2018
  8. 3/4 range-diff: make use of different output indicatorsStefan Beller, Aug 10, 2018
  9. Johannes SchindelinAug 13, 2018
  10. Stefan BellerAug 13, 2018
  11. 4/4 range-diff: indent special lines as contextStefan Beller, Aug 10, 2018
  12. Johannes SchindelinAug 13, 2018
  13. Stefan BellerAug 13, 2018
  14. Johannes SchindelinAug 14, 2018
  15. Stefan BellerAug 14, 2018
  16. Johannes SchindelinAug 16, 2018
  17. 0/3 Better colors in range-diffStefan Beller, Aug 17, 2018
  18. 1/3 diff.c: add --output-indicator-{new, old, context}Stefan Beller, Aug 17, 2018
  19. Johannes SchindelinAug 20, 2018
  20. Stefan BellerAug 20, 2018
  21. Johannes SchindelinAug 21, 2018
  22. diff.c: pass sign_index to emit_line_ws_markupStefan Beller, Aug 22, 2018
  23. Johannes SchindelinAug 23, 2018
  24. 2/3 range-diff: make use of different output indicatorsStefan Beller, Aug 17, 2018
  25. 3/3 range-diff: indent special lines as contextStefan Beller, Aug 17, 2018
  26. Junio C HamanoAug 17, 2018
  27. Stefan BellerAug 17, 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.