From d9c292e8bbd51c84cb9ecd86cb89b8a1b35a2a82 Mon Sep 17 00:00:00 2001 From: "Stephen R. van den Berg" Date: Sun, 27 Apr 2008 19:32:46 +0200 Subject: Simplify and fix --first-parent implementation The purpose of --first-parent is to view the tree without looking at side branche. This is accomplished by pretending there are no other parents than the first parent when encountering a merge. The current code marks the other parents as seen, which means that the tree traversal will behave differently depending on the order merges are handled. When a fast forward is artificially recorded as a merge, ----- / \ D---E---F---G master the current first-parent code considers E to be seen and stops the traversal after showing G and F. Signed-off-by: Stephen R. van den Berg Signed-off-by: Junio C Hamano --- revision.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'revision.c') diff --git a/revision.c b/revision.c index 4231ea2cce..bcfcd2a82b 100644 --- a/revision.c +++ b/revision.c @@ -415,7 +415,6 @@ static int add_parents_to_list(struct rev_info *revs, struct commit *commit, str { struct commit_list *parent = commit->parents; unsigned left_flag; - int add, rest; if (commit->object.flags & ADDED) return 0; @@ -462,19 +461,18 @@ static int add_parents_to_list(struct rev_info *revs, struct commit *commit, str 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) - insert_by_date(p, list); + insert_by_date(p, list); + if(revs->first_parent_only) + break; } return 0; } -- cgit v1.2.3 From ad1012ebde8be471098b5d476a98a02c76c8e75a Mon Sep 17 00:00:00 2001 From: Lars Hjemli Date: Mon, 12 May 2008 17:12:36 +0200 Subject: revision.c: really honor --first-parent In add_parents_to_list, if any parent of a revision had already been SEEN, the current code would continue with the next parent, skipping the test for --first-parent. This patch inverts the test for SEEN so that the test for --first-parent is always performed. Signed-off-by: Lars Hjemli Signed-off-by: Junio C Hamano --- revision.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'revision.c') diff --git a/revision.c b/revision.c index bcfcd2a82b..6f5b548a32 100644 --- a/revision.c +++ b/revision.c @@ -467,10 +467,10 @@ static int add_parents_to_list(struct rev_info *revs, struct commit *commit, str if (parse_commit(p) < 0) return -1; p->object.flags |= left_flag; - if (p->object.flags & SEEN) - continue; - p->object.flags |= SEEN; - insert_by_date(p, list); + if (!(p->object.flags & SEEN)) { + p->object.flags |= SEEN; + insert_by_date(p, list); + } if(revs->first_parent_only) break; } -- cgit v1.2.3