diff options
Diffstat (limited to 'revision.c')
-rw-r--r-- | revision.c | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/revision.c b/revision.c index 4231ea2cce..c947e0fa1e 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" @@ -1105,7 +1106,8 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch } } if (!strcmp(arg, "--parents")) { - revs->parents = 1; + revs->rewrite_parents = 1; + revs->print_parents = 1; continue; } if (!strcmp(arg, "--dense")) { @@ -1202,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; @@ -1396,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; } @@ -1524,13 +1541,13 @@ enum commit_action simplify_commit(struct rev_info *revs, struct commit *commit) /* Commit without changes? */ if (commit->object.flags & TREESAME) { /* drop merges unless we want parenthood */ - if (!revs->parents) + if (!revs->rewrite_parents) return commit_ignore; /* non-merge - always ignore it */ if (!commit->parents || !commit->parents->next) return commit_ignore; } - if (revs->parents && rewrite_parents(revs, commit) < 0) + if (revs->rewrite_parents && rewrite_parents(revs, commit) < 0) return commit_error; } return commit_show; @@ -1597,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; @@ -1704,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; +} |