From: Derrick Stolee <stolee@gmail.com>
To: Jeff King <peff@peff.net>,
Derrick Stolee via GitGitGadget <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, brad@brad-smith.co.uk,
sunshine@sunshineco.com, Derrick Stolee <dstolee@microsoft.com>,
Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH 1/3] graph: fix case that hit assert()
Date: Tue, 7 Jan 2020 13:47:54 -0500 [thread overview]
Message-ID: <d7a2e725-9866-61be-10ea-a21f16b88c2d@gmail.com> (raw)
In-Reply-To: <20200107153006.GA20591@coredump.intra.peff.net>
On 1/7/2020 10:30 AM, Jeff King wrote:
> On Tue, Jan 07, 2020 at 02:55:45PM +0000, Derrick Stolee via GitGitGadget wrote:
>
>> From: Derrick Stolee <dstolee@microsoft.com>
>>
>> A failure was reported in "git log --graph --all" with the new
>> graph-rendering logic. Create a test case that matches the
>> topology of that example and uses an explicit ref ordering instead
>> of the "--all" option. The test would fail with the following error:
>>
>> graph.c:1228: graph_output_collapsing_line: Assertion
>> `graph->mapping[i - 3] == target' failed.
>>
>> The situation is a little complicated, so let's break it down.
>
> First off, thanks for digging into this so promptly. Your solution looks
> correct to me. Everything else I'll mention here are nits. :)
>
> Your commit message starts off talking about the test, but without
> describing what's interesting about it. I think the answer is that we
> have two "skewed" merge parents for the same merge; maybe it would make
> sense to lead with that. I.e.:
>
> Subject: graph: drop assert() for merge with two collapsing parents
>
> When "git log --graph" shows a merge commit that has two collapsing
> lines, like:
>
> [your diagram]
>
> we trigger an assert():
>
> graph.c:1228: graph_output_collapsing_line: Assertion
> `graph->mapping[i - 3] == target' failed.
>
> ...and so on...
Good points.
>> The assert was introduced by eaf158f8 ("graph API: Use horizontal
>> lines for more compact graphs", 2009-04-21), which is quite old.
>> This assert is trying to say that when we complete a horizontal
>> line with a single slash, it is because we have reached our target.
>
> Thanks for this final sentence; writing that out in English made the
> purpose of the assert() much clearer.
>
> That could perhaps be an argument in favor of writing it as a BUG()
> with a similar human-readable explanation. I guess there was already a
> comment in the code, but it didn't quite click with me as much as what
> you wrote above.
>
>> It is actually the _second_ collapsing line that hits this assert.
>> The reason we are in this code path is because we are collapsing
>> the first line, and it in that case we are hitting our target now
>
> s/it//
>
>> that the horizontal line is complete. However, the second line
>> cannot be a horizontal line, so it will collapse without horizontal
>> lines. In this case, it is inappropriate to assert that we have
>> reached our target, as we need to continue for another column
>> before reaching the target. Dropping the assert is safe here.
>
> I think that makes sense. My big concern here is that the assert() was
> preventing us from looking out of bounds in the graph->mapping array,
> but I don't think that's the case here.
>
> Worth mentioning that this was due to 0f0f389f12 (graph: tidy up display
> of left-skewed merges, 2019-10-15), in case somebody has to later dig
> deeper?
Can do.
>> Second, the horizontal lines in that first line drop their coloring.
>> This is due to a use of graph_line_addch() instead of
>> graph_line_write_column(). Using a ternary operator to pick the
>> character is nice for compact code, but we actually need a column
>> to provide the color.
>
> It seems like this is a totally separate bug, and could be its own
> commit?
>
> I think it's also caused by 0f0f389f12, which actually introduced the
> seen_parent mechanism that you're correcting here.
You're right. These are better split. Any idea how to test the color?
(I'm pretty sure we have some tests for this... I can dig around.)
>> Helped-by: Jeff King <peff@peff.net>
>> Reported-by: Bradley Smith <brad@brad-smith.co.uk>
>
> I don't know that I did much, but OK. :)
>
> Thanks once again Bradley for the reproducible case.
>
>> diff --git a/t/t4215-log-skewed-merges.sh b/t/t4215-log-skewed-merges.sh
>> index 18709a723e..ddf6f6f5d3 100755
>> --- a/t/t4215-log-skewed-merges.sh
>> +++ b/t/t4215-log-skewed-merges.sh
>> @@ -240,4 +240,46 @@ test_expect_success 'log --graph with octopus merge with column joining its penu
>> EOF
>> '
>>
>> +test_expect_success 'log --graph with multiple tips' '
>
> This nicely covers the assert() problem. Could we check the same case
> with "--color" and test_decode_color to check the coloring issue (see
> t4214 for some prior art)?
Thanks for pointing me to existing color tests. I'll add one to my v2.
-Stolee
next prev parent reply other threads:[~2020-01-07 18:47 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-07 14:55 [PATCH 0/3] Fix two bugs in graph.c Derrick Stolee via GitGitGadget
2020-01-07 14:55 ` [PATCH 1/3] graph: fix case that hit assert() Derrick Stolee via GitGitGadget
2020-01-07 15:30 ` Jeff King
2020-01-07 18:47 ` Derrick Stolee [this message]
2020-01-07 19:21 ` Junio C Hamano
2020-01-07 19:31 ` Jeff King
2020-01-07 20:21 ` Junio C Hamano
2020-01-07 14:55 ` [PATCH 2/3] graph: replace assert() with graph_assert() macro Derrick Stolee via GitGitGadget
2020-01-07 15:36 ` Jeff King
2020-01-07 15:51 ` Eric Sunshine
2020-01-07 18:45 ` Derrick Stolee
2020-01-07 14:55 ` [PATCH 3/3] t4215: add bigger graph collapse test Derrick Stolee via GitGitGadget
2020-01-07 15:39 ` Jeff King
2020-01-07 18:02 ` Junio C Hamano
2020-01-07 18:04 ` Jeff King
2020-01-07 18:44 ` Derrick Stolee
2020-01-07 17:13 ` [PATCH 0/3] Fix two bugs in graph.c Junio C Hamano
2020-01-07 21:27 ` [PATCH v2 0/2] " Derrick Stolee via GitGitGadget
2020-01-07 21:27 ` [PATCH v2 1/2] graph: fix case that hit assert() Derrick Stolee via GitGitGadget
2020-01-07 21:50 ` Junio C Hamano
2020-01-08 17:34 ` Junio C Hamano
2020-01-08 19:14 ` Derrick Stolee
2020-01-07 21:27 ` [PATCH v2 2/2] graph: fix lack of color in horizontal lines Derrick Stolee via GitGitGadget
2020-01-07 21:51 ` 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:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d7a2e725-9866-61be-10ea-a21f16b88c2d@gmail.com \
--to=stolee@gmail.com \
--cc=brad@brad-smith.co.uk \
--cc=dstolee@microsoft.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=gitster@pobox.com \
--cc=peff@peff.net \
--cc=sunshine@sunshineco.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* 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.
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 NNTP newsgroup(s).