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

Re: [PATCH v2 3/3] diff-highlight: add support for --graph output.

From
Jeff King <peff@peff.net>
Date
Aug 19, 2016, 14:37 UTC
Message-ID
<20160819143725.eex2fcmbhn3s77or@sigill.intra.peff.net>
In-Reply-To
<20160817153124.7770-4-henderson.bj@gmail.com>
On Wed, Aug 17, 2016 at 08:31:24AM -0700, Brian Henderson wrote:
>  contrib/diff-highlight/diff-highlight | 16 ++++++++++------
>  1 file changed, 10 insertions(+), 6 deletions(-)

Junio already commented on the tests, and I think everything he said in his review is sensible.

As for the code itself, this looks much simpler than some of the things we discussed off-list, which is good. There is one place that you did not touch that I think is interesting: split_line.

It splits on $COLOR to mark those bits in their own list elements (so they can be skipped). But we don't do anything special for $GRAPH there.

Obviously it would be wrong to find $GRAPH in the middle of the line. But I think we end up in highlight_pair() with a sequence like this for each line:

  [
    color-graph,
    "|"
    color-reset,
    " ",
    ... possibly more graph pipes ...
    "-" (or "+")
    ... actual line data ...
  ]

We ignore "$COLOR" in the middle of that list, but not the other syntactic bits. I think this just works because we have to skip forward to the "-" or "+" element, and that happens to skip over all of the graph cruft, as well.

In a more general sense, it might have been better for split_line() to return a list of records, with each one containing a bit for "am I interesting?" along with the actual token data. But I think because the graph data cannot contain "-" or "+", it's acceptable to simply leave this as it is. It might be worth a comment (either in-code, or describing the strategy in the commit message).

-Peff
Previous: Brian HendersonNext: Eric Wong
Message 19 of 24 in “diff-highlight: add support for git log --graph output.”
  1. 0/3 diff-highlight: add support for git log --graph output.Brian Henderson, Jul 30, 2016
  2. 3/3 diff-highlight: add support for --graph output.Brian Henderson, Jul 30, 2016
  3. Junio C HamanoAug 1, 2016
  4. diff-highlight: Add comment for our assumption about --graph output.Brian Henderson, Aug 4, 2016
  5. 2/3 diff-highlight: add failing test for handling --graph output.Brian Henderson, Jul 30, 2016
  6. 1/3 diff-highlight: add some tests.Brian Henderson, Jul 30, 2016
  7. Eric WongAug 10, 2016
  8. Brian HendersonAug 15, 2016
  9. Junio C HamanoAug 15, 2016
  10. 0/3 diff-highlight: add support for git log --graph output.Brian Henderson, Aug 17, 2016
  11. 2/3 diff-highlight: add failing test for handling --graph output.Brian Henderson, Aug 17, 2016
  12. Junio C HamanoAug 17, 2016
  13. 1/3 diff-highlight: add some tests.Brian Henderson, Aug 17, 2016
  14. Junio C HamanoAug 17, 2016
  15. Brian HendersonAug 19, 2016
  16. Jeff KingAug 19, 2016
  17. Brian HendersonAug 19, 2016
  18. 3/3 diff-highlight: add support for --graph output.Brian Henderson, Aug 17, 2016
  19. Jeff KingAug 19, 2016
  20. Eric WongAug 19, 2016
  21. Jeff KingAug 19, 2016
  22. Lars SchneiderAug 15, 2016
  23. Junio C HamanoAug 16, 2016
  24. Lars SchneiderAug 24, 2016

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.