diff options
author | Junio C Hamano <gitster@pobox.com> | 2008-07-08 15:25:44 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2008-07-08 15:25:44 -0700 |
commit | 8bb65883d164843d5bb7475281af09bae18ab22d (patch) | |
tree | 7cf44a14a8aa1981ba814129948a4ed5918d3f88 /revision.c | |
parent | a32a4eaa36527ab1c9a999357f9edd5e04591a4a (diff) | |
parent | 85af7929ee125385c2771fa4eaccfa2f29dc63c9 (diff) | |
download | git-8bb65883d164843d5bb7475281af09bae18ab22d.tar.gz |
Merge branch 'jc/blame' (early part) into HEAD
* 'jc/blame' (early part):
git-blame --reverse
builtin-blame.c: allow more than 16 parents
builtin-blame.c: move prepare_final() into a separate function.
rev-list --children
revision traversal: --children option
Conflicts:
Documentation/rev-list-options.txt
revision.c
Diffstat (limited to 'revision.c')
-rw-r--r-- | revision.c | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/revision.c b/revision.c index fc66755259..5a1a948a41 100644 --- a/revision.c +++ b/revision.c @@ -10,6 +10,7 @@ #include "grep.h" #include "reflog-walk.h" #include "patch-ids.h" +#include "decorate.h" volatile show_early_output_fn_t show_early_output; @@ -1321,6 +1322,11 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch revs->no_walk = 0; continue; } + if (!strcmp(arg, "--children")) { + revs->children.name = "children"; + revs->limited = 1; + continue; + } opts = diff_opt_parse(&revs->diffopt, argv+i, argc-i); if (opts > 0) { @@ -1406,6 +1412,8 @@ 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"); + if (revs->rewrite_parents && revs->children.name) + die("cannot combine --parents and --children"); /* * Limitations on the graph functionality @@ -1419,6 +1427,26 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch return left; } +static void add_child(struct rev_info *revs, struct commit *parent, struct commit *child) +{ + struct commit_list *l = xcalloc(1, sizeof(*l)); + + l->item = child; + l->next = add_decoration(&revs->children, &parent->object, l); +} + +static void set_children(struct rev_info *revs) +{ + struct commit_list *l; + for (l = revs->commits; l; l = l->next) { + struct commit *commit = l->item; + struct commit_list *p; + + for (p = commit->parents; p; p = p->next) + add_child(revs, p->item, commit); + } +} + int prepare_revision_walk(struct rev_info *revs) { int nr = revs->pending.nr; @@ -1447,6 +1475,8 @@ int prepare_revision_walk(struct rev_info *revs) return -1; if (revs->topo_order) sort_in_topological_order(&revs->commits, revs->lifo); + if (revs->children.name) + set_children(revs); return 0; } @@ -1524,6 +1554,11 @@ static int commit_match(struct commit *commit, struct rev_info *opt) commit->buffer, strlen(commit->buffer)); } +static inline int want_ancestry(struct rev_info *revs) +{ + return (revs->rewrite_parents || revs->children.name); +} + enum commit_action simplify_commit(struct rev_info *revs, struct commit *commit) { if (commit->object.flags & SHOWN) @@ -1544,13 +1579,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->rewrite_parents) + if (!want_ancestry(revs)) return commit_ignore; /* non-merge - always ignore it */ if (!commit->parents || !commit->parents->next) return commit_ignore; } - if (revs->rewrite_parents && rewrite_parents(revs, commit) < 0) + if (want_ancestry(revs) && rewrite_parents(revs, commit) < 0) return commit_error; } return commit_show; |