From: Junio C Hamano Date: Wed, 21 May 2008 21:15:52 +0000 (-0700) Subject: Merge branch 'sv/first-parent' X-Git-Tag: v1.5.6-rc0~32 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/f0abea652bf90c5a081f07e35c4a656143e0ec50?ds=inline;hp=-c Merge branch 'sv/first-parent' * sv/first-parent: revision.c: really honor --first-parent Simplify and fix --first-parent implementation --- f0abea652bf90c5a081f07e35c4a656143e0ec50 diff --combined revision.c index c947e0fa1e,6f5b548a32..7142cf96cd --- a/revision.c +++ b/revision.c @@@ -6,7 -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" @@@ -416,7 -415,6 +416,6 @@@ static int add_parents_to_list(struct r { struct commit_list *parent = commit->parents; unsigned left_flag; - int add, rest; if (commit->object.flags & ADDED) return 0; @@@ -463,19 -461,18 +462,18 @@@ left_flag = (commit->object.flags & SYMMETRIC_LEFT); - rest = !revs->first_parent_only; - for (parent = commit->parents, add = 1; parent; add = rest) { + for (parent = commit->parents; parent; parent = parent->next) { struct commit *p = parent->item; - parent = parent->next; if (parse_commit(p) < 0) return -1; p->object.flags |= left_flag; - if (p->object.flags & SEEN) - continue; - p->object.flags |= SEEN; - if (add) + if (!(p->object.flags & SEEN)) { + p->object.flags |= SEEN; insert_by_date(p, list); + } + if(revs->first_parent_only) + break; } return 0; } @@@ -1106,8 -1103,7 +1104,8 @@@ int setup_revisions(int argc, const cha } } if (!strcmp(arg, "--parents")) { - revs->parents = 1; + revs->rewrite_parents = 1; + revs->print_parents = 1; continue; } if (!strcmp(arg, "--dense")) { @@@ -1204,12 -1200,6 +1202,12 @@@ 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; @@@ -1404,15 -1394,6 +1402,15 @@@ 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; } @@@ -1541,13 -1522,13 +1539,13 @@@ enum commit_action simplify_commit(stru /* 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; @@@ -1614,7 -1595,7 +1612,7 @@@ static void gc_boundary(struct object_a } } -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; @@@ -1721,11 -1702,3 +1719,11 @@@ 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; +}