git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] log --graph: draw '>' and '<' with --left-right
@ 2008-05-22 11:36 Johannes Schindelin
  2008-05-22 12:47 ` Johannes Schindelin
  0 siblings, 1 reply; 6+ messages in thread
From: Johannes Schindelin @ 2008-05-22 11:36 UTC (permalink / raw)
  To: Adam Simpkins; +Cc: git, gitster


Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 Documentation/technical/api-history-graph.txt |    2 +-
 graph.c                                       |   16 ++++++++++++++--
 graph.h                                       |    2 +-
 revision.c                                    |    2 +-
 4 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/Documentation/technical/api-history-graph.txt b/Documentation/technical/api-history-graph.txt
index ce1c08e..e955979 100644
--- a/Documentation/technical/api-history-graph.txt
+++ b/Documentation/technical/api-history-graph.txt
@@ -115,7 +115,7 @@ Sample usage
 
 ------------
 struct commit *commit;
-struct git_graph *graph = graph_init();
+struct git_graph *graph = graph_init(opts);
 
 while ((commit = get_revision(opts)) != NULL) {
 	graph_update(graph, commit);
diff --git a/graph.c b/graph.c
index 9d6ed30..85a9ba0 100644
--- a/graph.c
+++ b/graph.c
@@ -55,6 +55,10 @@ struct git_graph {
 	 */
 	struct commit *commit;
 	/*
+	 * For the --left-right option.
+	 */
+	struct rev_info *revs;
+	/*
 	 * The number of parents this commit has.
 	 * (Stored so we don't have to walk over them each time we need
 	 * this number)
@@ -125,10 +129,11 @@ struct git_graph {
 	int *new_mapping;
 };
 
-struct git_graph *graph_init(void)
+struct git_graph *graph_init(struct rev_info *opt)
 {
 	struct git_graph *graph = xmalloc(sizeof(struct git_graph));
 	graph->commit = NULL;
+	graph->revs = opt;
 	graph->num_parents = 0;
 	graph->expansion_row = 0;
 	graph->state = GRAPH_PADDING;
@@ -540,7 +545,14 @@ void graph_output_commit_line(struct git_graph *graph, struct strbuf *sb)
 
 		if (col_commit == graph->commit) {
 			seen_this = 1;
-			if (graph->num_parents > 1)
+			if (graph->revs && graph->revs->left_right) {
+				if (graph->commit->object.flags
+						& SYMMETRIC_LEFT)
+					strbuf_addch(sb, '<');
+				else
+					strbuf_addch(sb, '>');
+			}
+			else if (graph->num_parents > 1)
 				strbuf_addch(sb, 'M');
 			else
 				strbuf_addch(sb, '*');
diff --git a/graph.h b/graph.h
index a7748a5..eab4e3d 100644
--- a/graph.h
+++ b/graph.h
@@ -8,7 +8,7 @@ struct git_graph;
  * Create a new struct git_graph.
  * The graph should be freed with graph_release() when no longer needed.
  */
-struct git_graph *graph_init();
+struct git_graph *graph_init(struct rev_info *opt);
 
 /*
  * Destroy a struct git_graph and free associated memory.
diff --git a/revision.c b/revision.c
index 39ceef0..ce0f1ac 100644
--- a/revision.c
+++ b/revision.c
@@ -1206,7 +1206,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
 			if (!prefixcmp(arg, "--graph")) {
 				revs->topo_order = 1;
 				revs->rewrite_parents = 1;
-				revs->graph = graph_init();
+				revs->graph = graph_init(revs);
 				continue;
 			}
 			if (!strcmp(arg, "--root")) {
-- 
1.5.5.1.498.gaaa3c0

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

end of thread, other threads:[~2008-05-25  7:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-22 11:36 [PATCH] log --graph: draw '>' and '<' with --left-right Johannes Schindelin
2008-05-22 12:47 ` Johannes Schindelin
2008-05-22 13:14   ` Sverre Rabbelier
2008-05-25  5:27   ` Junio C Hamano
2008-05-25  6:43     ` Adam Simpkins
2008-05-25  7:07       ` [PATCH] log and rev-list: don't print extra prefixes already shown in the graph Adam Simpkins

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 NNTP newsgroup(s).