git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] graph: Fix log's graph's colors when merging branches.
@ 2013-10-17  6:52 Hemmo Nieminen
  2013-10-17  8:13 ` John Keeping
  0 siblings, 1 reply; 3+ messages in thread
From: Hemmo Nieminen @ 2013-10-17  6:52 UTC (permalink / raw)
  To: git

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



[-- Attachment #2: 0001-graph-Fix-log-s-graph-s-colors-when-merging-branches.patch --]
[-- Type: text/x-diff, Size: 1602 bytes --]

>From bdbefc100ceba66a70f540dfe2b1b09b0869f7ab Mon Sep 17 00:00:00 2001
From: Hemmo Nieminen <hemmo.nieminen@iki.fi>
Date: Wed, 16 Oct 2013 11:28:50 +0300
Subject: [PATCH] graph: Fix log's graph's colors when merging branches.

The log's graph's colors were off sometimes when merging several
branches. For example in the graph depicted below, the '-----.' part
following the asterisk was colored with incorrect colors. This was
caused by the fact that the leftmost branches, not part of the merge,
were not taken into account when calculating the column numbers
(colors).

  | |     Merge of http://members.cox.net/junkio/git-jc.git
  | |
  | *-----.   commit 211232bae64bcc60bbf5d1b5e5b2344c22ed767e
  | |\ \ \ \  Merge: fc54a9c 9e30dd7 c4b83e6 6602659 b28858b
  | | | | | | Author: Junio C Hamano <junkio@cox.net>

Signed-off-by: Hemmo Nieminen <hemmo.nieminen@iki.fi>
---
 graph.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/graph.c b/graph.c
index b24d04c..6404331 100644
--- a/graph.c
+++ b/graph.c
@@ -801,10 +801,10 @@ static int graph_draw_octopus_merge(struct git_graph *graph,
 	int num_dashes =
 		((graph->num_parents - dashless_commits) * 2) - 1;
 	for (i = 0; i < num_dashes; i++) {
-		col_num = (i / 2) + dashless_commits;
+		col_num = (i / 2) + dashless_commits + graph->commit_index;
 		strbuf_write_column(sb, &graph->new_columns[col_num], '-');
 	}
-	col_num = (i / 2) + dashless_commits;
+	col_num = (i / 2) + dashless_commits + graph->commit_index;
 	strbuf_write_column(sb, &graph->new_columns[col_num], '.');
 	return num_dashes + 1;
 }
-- 
1.8.4.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] graph: Fix log's graph's colors when merging branches.
  2013-10-17  6:52 [PATCH] graph: Fix log's graph's colors when merging branches Hemmo Nieminen
@ 2013-10-17  8:13 ` John Keeping
  2013-10-17 17:16   ` Hemmo Nieminen
  0 siblings, 1 reply; 3+ messages in thread
From: John Keeping @ 2013-10-17  8:13 UTC (permalink / raw)
  To: git

On Thu, Oct 17, 2013 at 09:52:09AM +0300, Hemmo Nieminen wrote:
> The log's graph's colors were off sometimes when merging several
> branches. For example in the graph depicted below, the '-----.' part
> following the asterisk was colored with incorrect colors. This was
> caused by the fact that the leftmost branches, not part of the merge,
> were not taken into account when calculating the column numbers
> (colors).
> 
>   | |     Merge of http://members.cox.net/junkio/git-jc.git
>   | |
>   | *-----.   commit 211232bae64bcc60bbf5d1b5e5b2344c22ed767e
>   | |\ \ \ \  Merge: fc54a9c 9e30dd7 c4b83e6 6602659 b28858b
>   | | | | | | Author: Junio C Hamano <junkio@cox.net>
> 
> Signed-off-by: Hemmo Nieminen <hemmo.nieminen@iki.fi>

It took me a minute to spot the problem when I tested this, but you're
right that there is a bug and I agree that the patch below is the right
fix.

Perhaps a better commit message will help others looking at this, maybe
something like this?

    graph: fix coloring around octopus merges

    When drawing the graph of an octopus merge, we draw a horizontal
    line from parents 3 and above into the asterisk representing the
    commit.  The sections of this line should be colored to match the
    graph lines coming in from above.

    However, if the commit is not in the left-most column we do not take
    into account the columns to the left of the commit when calculating
    these colors.  Fix this by adding the appropriate offset to the
    column index used for calculating the color.
    ---

    Commit 211232b (Octopus merge of the following five patches.,
    2005-05-05) in git.git's history exhibits this problem.

The section below the "---" does not become part of the commit message,
when the patch is added to Git, but is used for notes that might help
reviewers.

> ---
>  graph.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/graph.c b/graph.c
> index b24d04c..6404331 100644
> --- a/graph.c
> +++ b/graph.c
> @@ -801,10 +801,10 @@ static int graph_draw_octopus_merge(struct git_graph *graph,
>  	int num_dashes =
>  		((graph->num_parents - dashless_commits) * 2) - 1;
>  	for (i = 0; i < num_dashes; i++) {
> -		col_num = (i / 2) + dashless_commits;
> +		col_num = (i / 2) + dashless_commits + graph->commit_index;
>  		strbuf_write_column(sb, &graph->new_columns[col_num], '-');
>  	}
> -	col_num = (i / 2) + dashless_commits;
> +	col_num = (i / 2) + dashless_commits + graph->commit_index;
>  	strbuf_write_column(sb, &graph->new_columns[col_num], '.');
>  	return num_dashes + 1;
>  }

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] graph: Fix log's graph's colors when merging branches.
  2013-10-17  8:13 ` John Keeping
@ 2013-10-17 17:16   ` Hemmo Nieminen
  0 siblings, 0 replies; 3+ messages in thread
From: Hemmo Nieminen @ 2013-10-17 17:16 UTC (permalink / raw)
  To: John Keeping; +Cc: git

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

Hi,

On 09:13 Thu 17 Oct, John Keeping wrote:
> It took me a minute to spot the problem when I tested this, but you're
> right that there is a bug and I agree that the patch below is the right
> fix.
> 
> Perhaps a better commit message will help others looking at this, maybe
> something like this?

Updated the patch. Attaching it here.


-- 
Best Regards
Hemmo Nieminen


[-- Attachment #2: 0001-graph-fix-coloring-around-octopus-merges.patch --]
[-- Type: text/x-diff, Size: 1613 bytes --]

>From 46b7ae56e08bc8ca9c29697da2c1210bd2a242b0 Mon Sep 17 00:00:00 2001
From: Hemmo Nieminen <hemmo.nieminen@iki.fi>
Date: Wed, 16 Oct 2013 11:28:50 +0300
Subject: [PATCH v2] graph: fix coloring around octopus merges

When drawing the graph of an octopus merge, we draw a horizontal line
from parents 3 and above into the asterisk representing the commit. The
sections of this line should be colored to match the graph lines coming
in from above.

However, if the commit is not in the left-most column we do not take
into account the columns to the left of the commit when calculating
these colors. Fix this by adding the appropriate offset to the column
index used for calculating the color.

Signed-off-by: Hemmo Nieminen <hemmo.nieminen@iki.fi>
---

Notes:
    Commit 211232b (Octopus merge of the following five patches.,
    2005-05-05) in git.git's history exhibits this problem.

 graph.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/graph.c b/graph.c
index b24d04c..6404331 100644
--- a/graph.c
+++ b/graph.c
@@ -801,10 +801,10 @@ static int graph_draw_octopus_merge(struct git_graph *graph,
 	int num_dashes =
 		((graph->num_parents - dashless_commits) * 2) - 1;
 	for (i = 0; i < num_dashes; i++) {
-		col_num = (i / 2) + dashless_commits;
+		col_num = (i / 2) + dashless_commits + graph->commit_index;
 		strbuf_write_column(sb, &graph->new_columns[col_num], '-');
 	}
-	col_num = (i / 2) + dashless_commits;
+	col_num = (i / 2) + dashless_commits + graph->commit_index;
 	strbuf_write_column(sb, &graph->new_columns[col_num], '.');
 	return num_dashes + 1;
 }
-- 
1.8.4.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-10-17 17:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-17  6:52 [PATCH] graph: Fix log's graph's colors when merging branches Hemmo Nieminen
2013-10-17  8:13 ` John Keeping
2013-10-17 17:16   ` Hemmo Nieminen

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).