git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Noam Postavsky <npostavs@users.sourceforge.net>
Date
Jun 23, 2018, 21:45 UTC
Message-ID
<CAM-tV--dHGJbxfWGKrRde+Q2-cnmCXNshQtX4PN7jnMWER_+bg@mail.gmail.com>
In-Reply-To
<CAM-tV-9gAGBLsEh3=aa-bHT2DmJb=dfahq+kUW+0GLoc7eFq0w@mail.gmail.com>

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:
Show 18 quoted lines
> 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@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
Previous: Noam PostavskyNext: Jeff King
Message 7 of 22 in “[BUG] A part of an edge from an octopus merge gets colored, even with --color=never”
  1. Noam PostavskyMay 15, 2016
  2. Johannes SixtMay 17, 2016
  3. Jeff KingMay 17, 2016
  4. Jeff KingMay 17, 2016
  5. Jeff KingMay 17, 2016
  6. Noam PostavskyMay 20, 2016
  7. Noam PostavskyJun 23, 2018
  8. Jeff KingJun 25, 2018
  9. Noam PostavskyJun 30, 2018
  10. Noam PostavskyAug 6, 2018
  11. Jeff KingAug 6, 2018
  12. Jeff KingAug 6, 2018
  13. Noam PostavskySep 2, 2018
  14. Jeff KingSep 8, 2018
  15. Noam PostavskySep 25, 2018
  16. Noam PostavskyOct 3, 2018
  17. Jeff KingOct 3, 2018
  18. Noam PostavskyOct 3, 2018
  19. Jeff KingOct 9, 2018
  20. Noam PostavskyOct 10, 2018
  21. Johannes SixtMay 17, 2016
  22. Jeff KingMay 17, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.