git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Adam Simpkins <adam@adamsimpkins.net>
To: git@vger.kernel.org
Cc: Teemu Likonen <tlikonen@iki.fi>,
	Junio C Hamano <gitster@pobox.com>,
	Adam Simpkins <adam@adamsimpkins.net>
Subject: [PATCH 2/2] graph API: avoid printing unnecessary padding before some octopus merges
Date: Sun,  1 Jun 2008 13:56:58 -0700	[thread overview]
Message-ID: <1212353818-7031-3-git-send-email-adam@adamsimpkins.net> (raw)
In-Reply-To: <1212353818-7031-2-git-send-email-adam@adamsimpkins.net>

When an octopus merge is printed, several lines are printed before it to
move over existing branch lines to its right.  This is needed to make
room for the children of the octopus merge.  For example:

| | | |
| |  \ \
| |   \ \
| |    \ \
| M---. \ \
| |\ \ \ \ \

However, this step isn't necessary if there are no branch lines to the
right of the octopus merge.  Therefore, skip this step when it is not
needed, to avoid printing extra lines that don't really serve any
purpose.

Signed-off-by: Adam Simpkins <adam@adamsimpkins.net>
---
 graph.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/graph.c b/graph.c
index 332d1e8..0531716 100644
--- a/graph.c
+++ b/graph.c
@@ -450,16 +450,18 @@ void graph_update(struct git_graph *graph, struct commit *commit)
 	 * it never finished its output.  Goto GRAPH_SKIP, to print out
 	 * a line to indicate that portion of the graph is missing.
 	 *
-	 * Otherwise, if there are 3 or more parents, we need to print
-	 * extra rows before the commit, to expand the branch lines around
-	 * it and make room for it.
+	 * If there are 3 or more parents, we may need to print extra rows
+	 * before the commit, to expand the branch lines around it and make
+	 * room for it.  We need to do this unless there aren't any branch
+	 * rows to the right of this commit.
 	 *
 	 * If there are less than 3 parents, we can immediately print the
 	 * commit line.
 	 */
 	if (graph->state != GRAPH_PADDING)
 		graph->state = GRAPH_SKIP;
-	else if (graph->num_parents >= 3)
+	else if (graph->num_parents >= 3 &&
+		 graph->commit_index < (graph->num_columns - 1))
 		graph->state = GRAPH_PRE_COMMIT;
 	else
 		graph->state = GRAPH_COMMIT;
@@ -538,7 +540,8 @@ static void graph_output_skip_line(struct git_graph *graph, struct strbuf *sb)
 	strbuf_addstr(sb, "...");
 	graph_pad_horizontally(graph, sb);
 
-	if (graph->num_parents >= 3)
+	if (graph->num_parents >= 3 &&
+	    graph->commit_index < (graph->num_columns - 1))
 		graph_update_state(graph, GRAPH_PRE_COMMIT);
 	else
 		graph_update_state(graph, GRAPH_COMMIT);
-- 
1.5.6.rc0.54.g04bfd

  reply	other threads:[~2008-06-01 20:57 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-28 11:24 log --graph: extra space with --pretty=oneline Teemu Likonen
2008-05-28 11:34 ` Wincent Colaiuta
2008-05-29  8:57 ` Adam Simpkins
2008-05-29  9:03   ` [PATCH] graph API: improve output for merge commits (option 1) Adam Simpkins
2008-05-29  9:04   ` [PATCH] graph API: improve output for merge commits (option 2) Adam Simpkins
2008-05-29 10:25   ` log --graph: extra space with --pretty=oneline Teemu Likonen
2008-06-01 20:56   ` [PATCH 0/2] graph API: improve printing of merges Adam Simpkins
2008-06-01 20:56     ` [PATCH 1/2] graph API: improve display of merge commits Adam Simpkins
2008-06-01 20:56       ` Adam Simpkins [this message]
2008-06-01 21:50         ` [PATCH 2/2] graph API: avoid printing unnecessary padding before some octopus merges Junio C Hamano
2008-06-02  0:04           ` Adam Simpkins
2008-06-02  4:41             ` Junio C Hamano

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1212353818-7031-3-git-send-email-adam@adamsimpkins.net \
    --to=adam@adamsimpkins.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=tlikonen@iki.fi \
    /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.
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).