Re: [BUG] A part of an edge from an octopus merge gets colored, even with --color=never

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

On 20 May 2016 at 18:12, Noam Postavsky <npostavs@xxxxxxxxxxxxxxxxxxxxx> 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.
From d0c4f19ff162e63d5d23d456d0fc4fe9a32029ee Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@xxxxxxxxxxxxxxxxxxxxx>
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@xxxxxxxxxxxxxxxxxxxxx>
---
 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


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux