git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
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, 23 Jun 2018 17:45:19 -0400	[thread overview]
Message-ID: <CAM-tV--dHGJbxfWGKrRde+Q2-cnmCXNshQtX4PN7jnMWER_+bg@mail.gmail.com> (raw)
In-Reply-To: <CAM-tV-9gAGBLsEh3=aa-bHT2DmJb=dfahq+kUW+0GLoc7eFq0w@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 791 bytes --]

Archive link to previous discussion:
https://marc.info/?l=git&m=146331754420554&w=2

On 20 May 2016 at 18:12, Noam Postavsky <npostavs@users.sourceforge.net> wrote:

> Looking at the coloured output, for some octopus merges where the
> first parent edge immediately merges into the next column to the left,
> col_num should be decremented by 1 (otherwise the colour of the "-."
> doesn't match the rest of that edge).
>
> | | *-.
> | | |\ \
> | |/ / /
>
> For the other case where the first parent edge stays straight, the
> current col_num computation is correct.
>
> | *-.
> | |\ \
> | | | *
>
> I'm not sure how to distinguish these cases in the code though. Is it
> enough to just compare against graph->num_new_columns?

I was recently reminded of this, here's a patch which does that.

[-- Attachment #2: v1-0001-log-Fix-coloring-of-certain-octupus-merge-shapes.patch --]
[-- Type: text/x-diff, Size: 1512 bytes --]

From d0c4f19ff162e63d5d23d456d0fc4fe9a32029ee Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@users.sourceforge.net>
Date: Sat, 23 Jun 2018 16:56:43 -0400
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:

| *-.
| |\ \
| | | *

Signed-off-by: Noam Postavsky <npostavs@users.sourceforge.net>
---
 graph.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

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;
+	int first_col = dashless_commits + graph->commit_index;
+	int last_col = first_col + (num_dashes / 2);
+	if (last_col >= graph->num_new_columns) {
+		first_col--;
+		last_col--;
+	}
+	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], '.');
 	return num_dashes + 1;
 }
 
-- 
2.11.0


  reply	other threads:[~2018-06-23 21:45 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 [this message]
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
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--dHGJbxfWGKrRde+Q2-cnmCXNshQtX4PN7jnMWER_+bg@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).