[PATCH 0/2] Fix output of "git log --graph --boundary"
From: Adam Simpkins <hidden>
Date: 2016-06-15 22:44:38
These two patches fix the graph output when --boundary is used. They apply on top of a merge of my recent fixes for handling uninteresting commits (since they use the new graph_is_interesting() function I added), and Dscho's "--graph --left-right" changes (since these changes also need the struct rev_info). There were two small conflicts when merging Dscho's and my changes. I've including a merge diff below showing how I resolved them. Adam Simpkins (2): Fix output of "git log --graph --boundary" get_revision(): honor the topo_order flag for boundary commits graph.c | 87 ++++++++++++++++++++++++++++++++++++++++------------------- revision.c | 75 ++++++++++++++++++++++++++++++++++++++++----------- 2 files changed, 117 insertions(+), 45 deletions(-) 8acd45e94a0d42a0ceb164e294049104e0c0f663 diff --cc graph.c index ba9ede0,85a9ba0..479035d
--- a/graph.c
+++ b/graph.c@@@ -55,11 -55,13 +55,15 @@@ 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)
+ * The number of interesting parents that this commit has.
+ *
+ * Note that this is not the same as the actual number of parents.
+ * This count excludes parents that won't be printed in the graph
+ * output, as determined by graph_is_interesting().
*/
int num_parents;
/*
@@@ -565,18 -545,14 +570,28 @@@ void graph_output_commit_line(struct gi
if (col_commit == graph->commit) {
seen_this = 1;
+ /*
- * If the commit is a merge, print 'M'. Otherwise,
- * print '*'.
++ * If revs->left_right is set, print the '<' or '>'
++ * depending on which side this commit came from.
++ *
++ * If revs->left_right is not set and the commit is
++ * a merge, print 'M'. Otherwise, print '*'.
+ *
+ * Note that we don't check graph->num_parents to
+ * determine if the commit is a merge, since that
+ * only tracks the number of "interesting" parents.
+ * We want to print 'M' for merge commits even if
+ * they have less than 2 interesting parents.
+ */
- if (graph->commit->parents != NULL &&
- graph->commit->parents->next != NULL)
+ 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)
++ else if (graph->commit->parents != NULL &&
++ graph->commit->parents->next != NULL)
strbuf_addch(sb, 'M');
else
strbuf_addch(sb, '*');