aboutsummaryrefslogtreecommitdiff
path: root/revision.c
diff options
context:
space:
mode:
authorAdam Simpkins <adam@adamsimpkins.net>2008-05-04 03:36:54 -0700
committerJunio C Hamano <gitster@pobox.com>2008-05-05 18:46:35 -0700
commit7fefda5cc7a5faf7962092367bedb321a634d54d (patch)
treeb52dbe550af5064d586abfc07f2a0f61f31f7b73 /revision.c
parentc12172d2eab91b79b8181b04ab5a5332a96e34a8 (diff)
downloadgit-7fefda5cc7a5faf7962092367bedb321a634d54d.tar.gz
git-7fefda5cc7a5faf7962092367bedb321a634d54d.tar.xz
log and rev-list: add --graph option
This new option causes a text-based representation of the history to be printed to the left of the normal output. Signed-off-by: Adam Simpkins <adam@adamsimpkins.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'revision.c')
-rw-r--r--revision.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/revision.c b/revision.c
index a81330416..c947e0fa1 100644
--- a/revision.c
+++ b/revision.c
@@ -6,6 +6,7 @@
#include "diff.h"
#include "refs.h"
#include "revision.h"
+#include "graph.h"
#include "grep.h"
#include "reflog-walk.h"
#include "patch-ids.h"
@@ -1203,6 +1204,12 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
get_commit_format(arg+8, revs);
continue;
}
+ if (!prefixcmp(arg, "--graph")) {
+ revs->topo_order = 1;
+ revs->rewrite_parents = 1;
+ revs->graph = graph_init();
+ continue;
+ }
if (!strcmp(arg, "--root")) {
revs->show_root_diff = 1;
continue;
@@ -1397,6 +1404,15 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
if (revs->reverse && revs->reflog_info)
die("cannot combine --reverse with --walk-reflogs");
+ /*
+ * Limitations on the graph functionality
+ */
+ if (revs->reverse && revs->graph)
+ die("cannot combine --reverse with --graph");
+
+ if (revs->reflog_info && revs->graph)
+ die("cannot combine --walk-reflogs with --graph");
+
return left;
}
@@ -1598,7 +1614,7 @@ static void gc_boundary(struct object_array *array)
}
}
-struct commit *get_revision(struct rev_info *revs)
+static struct commit *get_revision_internal(struct rev_info *revs)
{
struct commit *c = NULL;
struct commit_list *l;
@@ -1705,3 +1721,11 @@ struct commit *get_revision(struct rev_info *revs)
return c;
}
+
+struct commit *get_revision(struct rev_info *revs)
+{
+ struct commit *c = get_revision_internal(revs);
+ if (c && revs->graph)
+ graph_update(revs->graph, c);
+ return c;
+}