git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: "Kyle J. McKay" <mackyle@gmail.com>
Cc: Git mailing list <git@vger.kernel.org>,
	Junio C Hamano <gitster@pobox.com>
Subject: [PATCH 4/5] graph: helper functions for printing commit header
Date: Thu, 29 Sep 2016 04:38:15 -0400	[thread overview]
Message-ID: <20160929083815.xgbdv62srna3cbg5@sigill.intra.peff.net> (raw)
In-Reply-To: <20160929083315.vwb3aurwbyjwlkjn@sigill.intra.peff.net>

The idea here is to make it possible to print something
right _before_ a commit in the graph. It's a bit ugly, but
it seems to work.

Signed-off-by: Jeff King <peff@peff.net>
---
 graph.c | 14 +++++++++++++-
 graph.h |  6 ++++++
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/graph.c b/graph.c
index d4e8519..56daa70 100644
--- a/graph.c
+++ b/graph.c
@@ -1218,7 +1218,7 @@ int graph_is_commit_finished(struct git_graph const *graph)
 	return (graph->state == GRAPH_PADDING);
 }
 
-void graph_show_commit(struct git_graph *graph)
+static void graph_show_commit_1(struct git_graph *graph, int only_pre)
 {
 	struct strbuf msgbuf = STRBUF_INIT;
 	int shown_commit_line = 0;
@@ -1239,6 +1239,8 @@ void graph_show_commit(struct git_graph *graph)
 	}
 
 	while (!shown_commit_line && !graph_is_commit_finished(graph)) {
+		if (only_pre && graph->state == GRAPH_COMMIT)
+			break;
 		shown_commit_line = graph_next_line(graph, &msgbuf);
 		fwrite(msgbuf.buf, sizeof(char), msgbuf.len,
 			graph->revs->diffopt.file);
@@ -1252,6 +1254,16 @@ void graph_show_commit(struct git_graph *graph)
 	strbuf_release(&msgbuf);
 }
 
+void graph_show_precommit(struct git_graph *graph)
+{
+	graph_show_commit_1(graph, 1);
+}
+
+void graph_show_commit(struct git_graph *graph)
+{
+	graph_show_commit_1(graph, 0);
+}
+
 void graph_show_oneline(struct git_graph *graph)
 {
 	struct strbuf msgbuf = STRBUF_INIT;
diff --git a/graph.h b/graph.h
index af62339..e13e97f 100644
--- a/graph.h
+++ b/graph.h
@@ -97,6 +97,12 @@ int graph_width(struct git_graph *graph);
  */
 void graph_show_commit(struct git_graph *graph);
 
+/*
+ * Same as graph_show_commit, but stop just _before_ printing
+ * the actual commit line.
+ */
+void graph_show_precommit(struct git_graph *graph);
+
 /*
  * If the graph is non-NULL, print one line of the history graph to stdout.
  * Does not print a terminating newline on the last line.
-- 
2.10.0.566.g5365f87


  parent reply	other threads:[~2016-09-29  8:38 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-29  5:34 [PATCH/RFC] git log --oneline alternative with dates, times and initials Kyle J. McKay
2016-09-29  8:33 ` Jeff King
2016-09-29  8:33   ` [PATCH 1/5] pretty: allow formatting DATE_SHORT Jeff King
2016-09-30  6:17     ` Jacob Keller
2016-09-30 10:56       ` SZEDER Gábor
2016-09-30 22:04         ` Jacob Keller
2016-10-01  9:18         ` Jeff King
2016-09-29  8:36   ` [PATCH 2/5] pretty: allow formatting names as initials Jeff King
2016-09-29 17:31     ` Junio C Hamano
2016-09-29 17:32       ` Jeff King
2016-09-29  8:37   ` [PATCH 3/5] graph: fix extra spaces in graph_padding_line Jeff King
2016-09-29  8:38   ` Jeff King [this message]
2016-09-29  8:38   ` [PATCH 5/5] log: add --commit-header option Jeff King
2016-09-29 17:49     ` Junio C Hamano
2016-09-29 18:31       ` Jeff King
2016-09-29 11:00   ` [PATCH/RFC] git log --oneline alternative with dates, times and initials Kyle J. McKay
2016-09-29 12:52     ` Jeff King
2016-09-29 17:38       ` Junio C Hamano
2016-09-29 18:30         ` Jeff King
2016-09-29 18:50           ` 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=20160929083815.xgbdv62srna3cbg5@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=mackyle@gmail.com \
    /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).