mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <>
Cc: Brian Henderson <>,
	Git Mailing List <>
Subject: Re: [BUG] log --graph corrupts patch
Date: Wed, 21 Mar 2018 01:47:19 -0400	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

On Tue, Mar 20, 2018 at 11:58:14AM -0400, Jeff King wrote:

> The issue bisects to 7e4ffb4c17 (diff-highlight: add support for --graph
> output, 2016-08-29). I think the problem is the "\s+" at the end of the
> $GRAPH regex, which soaks up the space for the context, and accidentally
> treats the "-" line as a preimage removal.
> But just switching that to "\s" doesn't quite work. We may have an
> arbitrary number of spaces between the graph ascii-art and the diff.
> E.g., if you have a commit at the base of a branch (the test in
> contrib/diff-highlight shows this case).
> So I think you'd have to record the indent of the previous hunk header,
> and then make sure that the indent matched that. But even there, I think
> we're subject to false positives if a commit message contains a hunk
> header (it's indented an extra 4 characters, but we'd accidentally soak
> that up thinking it was graph indentation).
> To make it bullet-proof, I think we'd have to actually parse the graph
> structure, finding a "*" line and then accepting only an indent that
> matched it.

Wow. Nerd snipe successful. This turned out to be quite tricky, but also
kind of interesting.

Here's a series which fixes it. The meaty bits are in the final commit;
the rest is just preparatory cleanup, and adding some tests (all are
cases which I managed to break while fixing this).

  [1/7]: diff-highlight: correct test graph diagram
  [2/7]: diff-highlight: use test_tick in graph test
  [3/7]: diff-highlight: prefer "echo" to "cat" in tests
  [4/7]: diff-highlight: test interleaved parallel lines of history
  [5/7]: diff-highlight: test graphs with --color
  [6/7]: diff-highlight: factor out flush_hunk() helper
  [7/7]: diff-highlight: detect --graph by indent

 contrib/diff-highlight/       | 89 +++++++++++++++----
 .../diff-highlight/t/  | 81 +++++++++++++----
 2 files changed, 133 insertions(+), 37 deletions(-)


  reply	other threads:[~2018-03-21  5:47 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-19 10:21 [BUG] log --graph corrupts patch Phillip Wood
2018-03-20  6:09 ` Jeff King
2018-03-20  9:58   ` Phillip Wood
2018-03-20 15:58     ` Jeff King
2018-03-21  5:47       ` Jeff King [this message]
2018-03-21  5:47         ` [PATCH 1/7] diff-highlight: correct test graph diagram Jeff King
2018-03-21  5:48         ` [PATCH 2/7] diff-highlight: use test_tick in graph test Jeff King
2018-03-21  5:48         ` [PATCH 3/7] diff-highlight: prefer "echo" to "cat" in tests Jeff King
2018-03-21  5:49         ` [PATCH 4/7] diff-highlight: test interleaved parallel lines of history Jeff King
2018-03-21  5:49         ` [PATCH 5/7] diff-highlight: test graphs with --color Jeff King
2018-03-21  5:56         ` [PATCH 6/7] diff-highlight: use flush() helper consistently Jeff King
2018-03-21  5:59         ` [PATCH 7/7] diff-highlight: detect --graph by indent Jeff King
2018-03-22 10:59           ` Phillip Wood
2018-03-22 11:18             ` Jeff King
2018-03-21 17:23         ` [BUG] log --graph corrupts patch Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).