From: Jeff King <peff@peff.net>
To: Noam Postavsky <npostavs@users.sourceforge.net>
Cc: Johannes Sixt <j6t@kdbg.org>,
Hemmo Nieminen <hemmo.nieminen@iki.fi>,
git@vger.kernel.org
Subject: Re: [BUG] A part of an edge from an octopus merge gets colored, even with --color=never
Date: Mon, 25 Jun 2018 12:23:09 -0400 [thread overview]
Message-ID: <20180625162308.GA13719@sigill.intra.peff.net> (raw)
In-Reply-To: <CAM-tV--dHGJbxfWGKrRde+Q2-cnmCXNshQtX4PN7jnMWER_+bg@mail.gmail.com>
On Sat, Jun 23, 2018 at 05:45:19PM -0400, Noam Postavsky wrote:
> On 20 May 2016 at 18:12, Noam Postavsky <npostavs@users.sourceforge.net> wrote:
My, this is a blast from the past. :)
> Subject: [PATCH v1] log: Fix coloring of certain octupus merge shapes
>
> For octopus merges where the first parent edge immediately merges into
> the next column to the left:
>
> | | *-.
> | | |\ \
> | |/ / /
>
> then the number of columns should be one less than the usual case:
>
> | *-.
> | |\ \
> | | | *
These diagrams confused me for a minute, because I see two differences:
1. The first one has an extra apparently unrelated parallel branch on
the far left.
2. The first has the first-parent of the "*" merge commit immediately
join the branch.
But if I understand correctly, we only care about the second property.
So would it be accurate to show them as:
| *-.
| |\ \
|/ / /
| *-.
| |\ \
| | | *
?
I think that makes it easier to compare them.
I don't remember much about our prior discussion, so let me try to talk
myself through the patch itself:
> diff --git a/graph.c b/graph.c
> index e1f6d3bdd..c919c86e8 100644
> --- a/graph.c
> +++ b/graph.c
> @@ -856,12 +856,16 @@ static int graph_draw_octopus_merge(struct git_graph *graph,
> int col_num, i;
> int num_dashes =
> ((graph->num_parents - dashless_commits) * 2) - 1;
> - for (i = 0; i < num_dashes; i++) {
> - col_num = (i / 2) + dashless_commits + graph->commit_index;
OK, so the old code emitted num_dashes, and every pair was done with the
same column. Our highest iteration of this loop would use the column at
(num_dashes-1) / 2. We know that num_dashes is always odd, so:
num_dashes = 1 puts our last column at 0
num_dashes = 3 puts our last column at 1
And so on. So far so good.
> + int first_col = dashless_commits + graph->commit_index;
This corresponds to the i=0 case, makes sense.
> + int last_col = first_col + (num_dashes / 2);
But here our last_col misses the "-1". I don't think it matters because
we know num_dashes is always odd, and therefore due to integer
truncation (num_dashes-1)/2 == (num_dashes/2).
> + if (last_col >= graph->num_new_columns) {
> + first_col--;
> + last_col--;
> + }
The shifting of last_col I expect as part of the fix. I was surprised by
shifting first_col, though. Wouldn't it always start at 0 (offset by the
previous commits)? It definitely seems to be necessary, but I'm not sure
I understand why.
> + for (i = 0, col_num = first_col; i < num_dashes; i++, col_num++) {
> strbuf_write_column(sb, &graph->new_columns[col_num], '-');
> }
> - col_num = (i / 2) + dashless_commits + graph->commit_index;
> - strbuf_write_column(sb, &graph->new_columns[col_num], '.');
> + strbuf_write_column(sb, &graph->new_columns[last_col], '.');
In this new loop we count up our dashes and our columns. But now we have
1-to-1 correspondence as we increment! I don't think that can be right.
And indeed, if I take your original problem report and add an extra "d"
branch and make the octopus "a b d", then the problem comes back. You
don't notice with a 3-parent merge because
We need to increment col_num only half as much as num_dashes. Should we
be doing:
for (col_num = first_col; col_num < last_col; col_num++) {
strbuf_write_column(sb, &graph->new_columns[col_num], '-');
strbuf_write_column(sb, &graph->new_columns[col_num], '-');
}
strbuf_write_column(sb, &graph->new_columns[last_col], '-');
strbuf_write_column(sb, &graph->new_columns[last_col], '.');
I.e., write "--" for each interior column, and then "-." for the last
one?
-Peff
next prev parent reply other threads:[~2018-06-25 16:23 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-15 13:05 [BUG] A part of an edge from an octopus merge gets colored, even with --color=never Noam Postavsky
2016-05-17 19:07 ` Johannes Sixt
2016-05-17 19:45 ` Jeff King
2016-05-17 19:51 ` Jeff King
2016-05-17 19:55 ` Jeff King
2016-05-20 22:12 ` Noam Postavsky
2018-06-23 21:45 ` Noam Postavsky
2018-06-25 16:23 ` Jeff King [this message]
2018-06-30 12:47 ` Noam Postavsky
2018-08-06 18:34 ` Noam Postavsky
2018-08-06 21:28 ` Jeff King
2018-08-06 21:26 ` Jeff King
2018-09-02 0:34 ` Noam Postavsky
2018-09-08 16:13 ` Jeff King
2018-09-25 0:27 ` Noam Postavsky
2018-10-03 0:09 ` Noam Postavsky
2018-10-03 4:24 ` Jeff King
2018-10-03 22:32 ` Noam Postavsky
2018-10-09 4:51 ` Jeff King
2018-10-10 0:42 ` Noam Postavsky
2016-05-17 20:02 ` Johannes Sixt
2016-05-17 21:57 ` Jeff King
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=20180625162308.GA13719@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=hemmo.nieminen@iki.fi \
--cc=j6t@kdbg.org \
--cc=npostavs@users.sourceforge.net \
/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).