From: Noam Postavsky <npostavs@users.sourceforge.net>
To: Jeff King <peff@peff.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: Sat, 1 Sep 2018 20:34:41 -0400 [thread overview]
Message-ID: <CAM-tV-_=4WuMGemm6RTB902-m8JfMKGp_OkQFuJMagPE8bOOtg@mail.gmail.com> (raw)
In-Reply-To: <20180806212603.GA21026@sigill.intra.peff.net>
[-- Attachment #1: Type: text/plain, Size: 486 bytes --]
On 6 August 2018 at 17:26, Jeff King <peff@peff.net> wrote:
> I suspect it still has a bug, which is that it is handling this
> first-parent-goes-left case, but probably gets the straight-parent case
> wrong. But at least in this form, I think it is obvious to see where
> that bug is (the "three" in the comment is not accurate in that latter
> case, and it should be two).
Yes, thanks, it makes a lot more sense this way. I believe the
attached handles both parent types correctly.
[-- Attachment #2: v3-0001-log-Fix-coloring-of-certain-octupus-merge-shapes.patch --]
[-- Type: text/x-diff, Size: 2819 bytes --]
From a841a50b016c0cfc9183384e6c3ca85a23d1e11f Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@users.sourceforge.net>
Date: Sat, 1 Sep 2018 20:07:16 -0400
Subject: [PATCH v3] 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:
| *-.
| |\ \
| | | *
Also refactor the code to iterate over columns rather than dashes,
building from an initial patch suggestion by Jeff King.
Signed-off-by: Noam Postavsky <npostavs@users.sourceforge.net>
---
graph.c | 48 ++++++++++++++++++++++++++++++++++++------------
1 file changed, 36 insertions(+), 12 deletions(-)
diff --git a/graph.c b/graph.c
index e1f6d3bdd..478c86dfb 100644
--- a/graph.c
+++ b/graph.c
@@ -848,21 +848,45 @@ static int graph_draw_octopus_merge(struct git_graph *graph,
struct strbuf *sb)
{
/*
- * Here dashless_commits represents the number of parents
- * which don't need to have dashes (because their edges fit
- * neatly under the commit).
+ * Here dashless_commits represents the number of parents which don't
+ * need to have dashes (because their edges fit neatly under the
+ * commit). And dashful_commits are the remaining ones.
*/
const int dashless_commits = 2;
- 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;
- strbuf_write_column(sb, &graph->new_columns[col_num], '-');
+ int dashful_commits = graph->num_parents - dashless_commits;
+
+ /*
+ * Usually, each parent gets its own column, like this:
+ *
+ * | *-.
+ * | |\ \
+ * | | | *
+ *
+ * Sometimes the first parent goes into an existing column, like this:
+ *
+ * | *-.
+ * | |\ \
+ * |/ / /
+ *
+ */
+ int parent_in_existing_cols = graph->num_parents -
+ (graph->num_new_columns - graph->num_columns);
+
+ /*
+ * Draw the dashes. We start in the column following the
+ * dashless_commits, but subtract out the parent which goes to an
+ * existing column: we've already counted that column in commit_index.
+ */
+ int first_col = graph->commit_index + dashless_commits
+ - parent_in_existing_cols;
+ int i;
+
+ for (i = 0; i < dashful_commits; i++) {
+ strbuf_write_column(sb, &graph->new_columns[i+first_col], '-');
+ strbuf_write_column(sb, &graph->new_columns[i+first_col],
+ i == dashful_commits-1 ? '.' : '-');
}
- col_num = (i / 2) + dashless_commits + graph->commit_index;
- strbuf_write_column(sb, &graph->new_columns[col_num], '.');
- return num_dashes + 1;
+ return 2 * dashful_commits;
}
static void graph_output_commit_line(struct git_graph *graph, struct strbuf *sb)
--
2.11.0
next prev parent reply other threads:[~2018-09-02 0:35 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
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 [this message]
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='CAM-tV-_=4WuMGemm6RTB902-m8JfMKGp_OkQFuJMagPE8bOOtg@mail.gmail.com' \
--to=npostavs@users.sourceforge.net \
--cc=git@vger.kernel.org \
--cc=hemmo.nieminen@iki.fi \
--cc=j6t@kdbg.org \
--cc=peff@peff.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).