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

Re: [showing-off RFC/PATCH 26/26] diff.c: have a "machine parseable" move coloring

From
Stefan Beller <sbeller@google.com>
Date
Jun 21, 2017, 22:40 UTC
Message-ID
<CAGZ79kYDBZG4AOueJjvQ61yyC-DQk-8cb5-y18fg2k4JUsQPKw@mail.gmail.com>
In-Reply-To
<xmqqh8z9m2ed.fsf@gitster.mtv.corp.google.com>
On Wed, Jun 21, 2017 at 2:55 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 26 quoted lines
> Brandon Williams <bmwill@google.com> writes:
>
>> On 06/19, Stefan Beller wrote:
>>> Ævar asked for it, this is how you would do it.
>>> (plus documentation, tests, CLI knobs, options)
>>>
>>> Signed-off-by: Stefan Beller <sbeller@google.com>
>>> ---
>>>  diff.c | 15 +++++++++++----
>>>  diff.h |  2 ++
>>>  2 files changed, 13 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/diff.c b/diff.c
>>> index 7756f7610c..61caa057ff 100644
>>> --- a/diff.c
>>> +++ b/diff.c
>>> @@ -997,6 +997,7 @@ static void emit_diff_symbol_from_struct(struct diff_options *o,
>>>      static const char *nneof = " No newline at end of file\n";
>>>      const char *context, *reset, *set, *meta, *fraginfo;
>>>      struct strbuf sb = STRBUF_INIT;
>>> +    int sign;
>>
>> should this be a char instead of an int?
>
> Perhaps.  Once we start adding things other than + and -, I think
> they should no longer be called "sign", though.

Well 'sign' is currently meant as a mathematical operation, but it could also be meant as a street sign?

The empty sign ' ' tells you it is context, and not subject to bikeshedding whilst reviewing a patch. :)

Show 5 quoted lines
>
> If Stefan chose '*' as a replacement for '+' because both makes
> things larger (yes, I am a positive person and my numbers are all
> positive), probably the replacement for '-' should be '/' (or '%'),
> not '_'.  But that is just bikeshedding.

I was trying to choose characters that sort of resembled the shape, but slightly differently. But a machine would not care any ways.

There was also temptation to use bogus signs like 'M' and 'm' for moved (capital M for + and lower m for -, obviously).

But this is a proof of concept on top of the series showing that this way with bits set in the flags field we do not need to have colors. The older series was operating on the colors and by that figuring out if it was say at a boundary, but here we would just use the flagbits to come up with a reasonable first character. (for example: Would the machine parse-able format also care about dimming? I defer such a discussion in the future.)

Previous: Junio C HamanoNext: Stefan Beller
Message 80 of 125 in “[PATCHv5 00/17] Diff machine: highlight moved lines.”
  1. Stefan BellerMay 24, 2017
  2. 01/17 diff: readability fixStefan Beller, May 24, 2017
  3. 03/17 diff.c: factor out diff_flush_patch_all_file_pairsStefan Beller, May 24, 2017
  4. 09/17 submodule.c: convert show_submodule_summary to use emit_line_fmtStefan Beller, May 24, 2017
  5. 04/17 diff: introduce more flexible emit functionStefan Beller, May 24, 2017
  6. Jonathan TanJun 13, 2017
  7. Stefan BellerJun 13, 2017
  8. Jonathan TanJun 13, 2017
  9. 05/17 diff.c: convert fn_out_consume to use emit_lineStefan Beller, May 24, 2017
  10. 02/17 diff: move line ending check into emit_hunk_headerStefan Beller, May 24, 2017
  11. 07/17 diff.c: convert emit_rewrite_diff to use emit_line_*Stefan Beller, May 24, 2017
  12. 15/17 diff.c: emit_line includes whitespace highlightingStefan Beller, May 24, 2017
  13. 11/17 diff.c: convert show_stats to use emit_line_*Stefan Beller, May 24, 2017
  14. 17/17 diff.c: color moved lines differentlyStefan Beller, May 24, 2017
  15. Junio C HamanoMay 25, 2017
  16. Stefan BellerMay 25, 2017
  17. 10/17 diff.c: convert emit_binary_diff_body to use emit_line_*Stefan Beller, May 24, 2017
  18. 08/17 diff.c: convert emit_rewrite_lines to use emit_line_*Stefan Beller, May 24, 2017
  19. 16/17 diff: buffer all output if asked toStefan Beller, May 24, 2017
  20. Junio C HamanoMay 25, 2017
  21. Stefan BellerMay 25, 2017
  22. Junio C HamanoMay 26, 2017
  23. Jonathan TanJun 13, 2017
  24. Stefan BellerJun 14, 2017
  25. 12/17 diff.c: convert word diffing to use emit_line_*Stefan Beller, May 24, 2017
  26. 14/17 diff.c: convert diff_summary to use emit_line_*Stefan Beller, May 24, 2017
  27. 13/17 diff.c: convert diff_flush to use emit_line_*Stefan Beller, May 24, 2017
  28. 06/17 diff.c: convert builtin_diff to use emit_line_*Stefan Beller, May 24, 2017
  29. Junio C HamanoMay 25, 2017
  30. Stefan BellerMay 25, 2017
  31. Junio C HamanoMay 26, 2017
  32. Stefan BellerMay 26, 2017
  33. 0/1 Diff machine: highlight moved lines.Stefan Beller, May 27, 2017
  34. 1/1 diff.c: color moved lines differentlyStefan Beller, May 27, 2017
  35. Philip OakleyMay 27, 2017
  36. Stefan BellerMay 30, 2017
  37. diff.c: color moved lines differentlyStefan Beller, Jun 1, 2017
  38. Jonathan TanJun 13, 2017
  39. Stefan BellerJun 14, 2017
  40. 00/26 reroll of sb/diff-color-movedStefan Beller, Jun 20, 2017
  41. 02/26 diff.c: move line ending check into emit_hunk_headerStefan Beller, Jun 20, 2017
  42. 03/26 diff.c: factor out diff_flush_patch_all_file_pairsStefan Beller, Jun 20, 2017
  43. 06/26 diff.c: emit_diff_symbol learns DIFF_SYMBOL_CONTEXT_FRAGINFOStefan Beller, Jun 20, 2017
  44. 07/26 diff.c: emit_diff_symbol learns DIFF_SYMBOL_NO_LF_EOFStefan Beller, Jun 20, 2017
  45. 08/26 diff.c: migrate emit_line_checked to use emit_diff_symbolStefan Beller, Jun 20, 2017
  46. Junio C HamanoJun 21, 2017
  47. Stefan BellerJun 22, 2017
  48. Stefan BellerJun 22, 2017
  49. Junio C HamanoJun 23, 2017
  50. 11/26 diff.c: emit_diff_symbol learns DIFF_SYMBOL_FILEPAIRStefan Beller, Jun 20, 2017
  51. Jonathan TanJun 20, 2017
  52. Junio C HamanoJun 21, 2017
  53. Stefan BellerJun 22, 2017
  54. 04/26 diff.c: introduce emit_diff_symbolStefan Beller, Jun 20, 2017
  55. Junio C HamanoJun 21, 2017
  56. Stefan BellerJun 21, 2017
  57. Junio C HamanoJun 21, 2017
  58. Junio C HamanoJun 21, 2017
  59. Stefan BellerJun 21, 2017
  60. Junio C HamanoJun 21, 2017
  61. Stefan BellerJun 21, 2017
  62. Brandon WilliamsJun 21, 2017
  63. Junio C HamanoJun 21, 2017
  64. Brandon WilliamsJun 21, 2017
  65. 15/26 submodule.c: migrate diff output to use emit_diff_symbolStefan Beller, Jun 20, 2017
  66. Jonathan TanJun 20, 2017
  67. 19/26 diff.c: emit_diff_symbol learns about DIFF_SYMBOL_STAT_SEPStefan Beller, Jun 20, 2017
  68. 12/26 diff.c: emit_diff_symbol learns DIFF_SYMBOL_HEADERStefan Beller, Jun 20, 2017
  69. 17/26 diff.c: convert show_stats to use emit_diff_symbolStefan Beller, Jun 20, 2017
  70. Brandon WilliamsJun 21, 2017
  71. Stefan BellerJun 21, 2017
  72. 18/26 diff.c: convert word diffing to use emit_diff_symbolStefan Beller, Jun 20, 2017
  73. 25/26 diff: document the new --color-moved settingStefan Beller, Jun 20, 2017
  74. 14/26 diff.c: emit_diff_symbol learns DIFF_SYMBOL_REWRITE_DIFFStefan Beller, Jun 20, 2017
  75. 26/26 diff.c: have a "machine parseable" move coloringStefan Beller, Jun 20, 2017
  76. Stefan BellerJun 20, 2017
  77. Ævar Arnfjörð BjarmasonJun 23, 2017
  78. Brandon WilliamsJun 21, 2017
  79. Junio C HamanoJun 21, 2017
  80. Stefan BellerJun 21, 2017
  81. 20/26 diff.c: emit_diff_symbol learns about DIFF_SYMBOL_SUMMARYStefan Beller, Jun 20, 2017
  82. 21/26 diff.c: buffer all output if asked toStefan Beller, Jun 20, 2017
  83. 24/26 diff.c: add dimming to moved line detectionStefan Beller, Jun 20, 2017
  84. Junio C HamanoJun 21, 2017
  85. 16/26 diff.c: convert emit_binary_diff_body to use emit_diff_symbolStefan Beller, Jun 20, 2017
  86. Junio C HamanoJun 21, 2017
  87. 23/26 diff.c: color moved lines differently, plain modeStefan Beller, Jun 20, 2017
  88. 09/26 diff.c: emit_diff_symbol learns DIFF_SYMBOL_WORDS{_PORCELAIN}Stefan Beller, Jun 20, 2017
  89. 22/26 diff.c: color moved lines differentlyStefan Beller, Jun 20, 2017
  90. Jonathan TanJun 20, 2017
  91. Stefan BellerJun 20, 2017
  92. 05/26 diff.c: emit_diff_symbol learns DIFF_SYMBOL_CONTEXT_MARKERStefan Beller, Jun 20, 2017
  93. 10/26 diff.c: emit_diff_symbol learns DIFF_SYMBOL_CONTEXT_INCOMPLETEStefan Beller, Jun 20, 2017
  94. 13/26 diff.c: emit_diff_symbol learns about DIFF_SYMBOL_BINARY_FILESStefan Beller, Jun 20, 2017
  95. Junio C HamanoJun 21, 2017
  96. Stefan BellerJun 21, 2017
  97. 01/26 diff.c: readability fixStefan Beller, Jun 20, 2017
  98. 00/25 reroll of sb/diff-color-movedStefan Beller, Jun 23, 2017
  99. 02/25 diff.c: move line ending check into emit_hunk_headerStefan Beller, Jun 23, 2017
  100. 04/25 diff.c: introduce emit_diff_symbolStefan Beller, Jun 23, 2017
  101. Junio C HamanoJun 23, 2017
  102. Stefan BellerJun 23, 2017
  103. 06/25 diff.c: emit_diff_symbol learns DIFF_SYMBOL_CONTEXT_FRAGINFOStefan Beller, Jun 23, 2017
  104. 03/25 diff.c: factor out diff_flush_patch_all_file_pairsStefan Beller, Jun 23, 2017
  105. 05/25 diff.c: emit_diff_symbol learns DIFF_SYMBOL_CONTEXT_MARKERStefan Beller, Jun 23, 2017
  106. 09/25 diff.c: emit_diff_symbol learns DIFF_SYMBOL_WORDS[_PORCELAIN]Stefan Beller, Jun 23, 2017
  107. 07/25 diff.c: emit_diff_symbol learns DIFF_SYMBOL_NO_LF_EOFStefan Beller, Jun 23, 2017
  108. 13/25 diff.c: emit_diff_symbol learns about DIFF_SYMBOL_BINARY_FILESStefan Beller, Jun 23, 2017
  109. 12/25 diff.c: emit_diff_symbol learns DIFF_SYMBOL_HEADERStefan Beller, Jun 23, 2017
  110. 14/25 diff.c: emit_diff_symbol learns DIFF_SYMBOL_REWRITE_DIFFStefan Beller, Jun 23, 2017
  111. 23/25 diff.c: color moved lines differently, plain modeStefan Beller, Jun 23, 2017
  112. 22/25 diff.c: color moved lines differentlyStefan Beller, Jun 23, 2017
  113. 15/25 submodule.c: migrate diff output to use emit_diff_symbolStefan Beller, Jun 23, 2017
  114. 25/25 diff: document the new --color-moved settingStefan Beller, Jun 23, 2017
  115. 11/25 diff.c: emit_diff_symbol learns DIFF_SYMBOL_FILEPAIR_{PLUS, MINUS}Stefan Beller, Jun 23, 2017
  116. 24/25 diff.c: add dimming to moved line detectionStefan Beller, Jun 23, 2017
  117. 01/25 diff.c: readability fixStefan Beller, Jun 23, 2017
  118. 10/25 diff.c: emit_diff_symbol learns DIFF_SYMBOL_CONTEXT_INCOMPLETEStefan Beller, Jun 23, 2017
  119. 21/25 diff.c: buffer all output if asked toStefan Beller, Jun 23, 2017
  120. 08/25 diff.c: migrate emit_line_checked to use emit_diff_symbolStefan Beller, Jun 23, 2017
  121. 18/25 diff.c: convert word diffing to use emit_diff_symbolStefan Beller, Jun 23, 2017
  122. 17/25 diff.c: convert show_stats to use emit_diff_symbolStefan Beller, Jun 23, 2017
  123. 19/25 diff.c: emit_diff_symbol learns about DIFF_SYMBOL_STAT_SEPStefan Beller, Jun 23, 2017
  124. 20/25 diff.c: emit_diff_symbol learns about DIFF_SYMBOL_SUMMARYStefan Beller, Jun 23, 2017
  125. 16/25 diff.c: convert emit_binary_diff_body to use emit_diff_symbolStefan Beller, Jun 23, 2017

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.