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 <srb@cuci.nl> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
f0ec47b8e7
commit
d9c292e8bb
10
revision.c
10
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;
|
struct commit_list *parent = commit->parents;
|
||||||
unsigned left_flag;
|
unsigned left_flag;
|
||||||
int add, rest;
|
|
||||||
|
|
||||||
if (commit->object.flags & ADDED)
|
if (commit->object.flags & ADDED)
|
||||||
return 0;
|
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);
|
left_flag = (commit->object.flags & SYMMETRIC_LEFT);
|
||||||
|
|
||||||
rest = !revs->first_parent_only;
|
for (parent = commit->parents; parent; parent = parent->next) {
|
||||||
for (parent = commit->parents, add = 1; parent; add = rest) {
|
|
||||||
struct commit *p = parent->item;
|
struct commit *p = parent->item;
|
||||||
|
|
||||||
parent = parent->next;
|
|
||||||
if (parse_commit(p) < 0)
|
if (parse_commit(p) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
p->object.flags |= left_flag;
|
p->object.flags |= left_flag;
|
||||||
if (p->object.flags & SEEN)
|
if (p->object.flags & SEEN)
|
||||||
continue;
|
continue;
|
||||||
p->object.flags |= SEEN;
|
p->object.flags |= SEEN;
|
||||||
if (add)
|
insert_by_date(p, list);
|
||||||
insert_by_date(p, list);
|
if(revs->first_parent_only)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user