git-log --first-parent: show only the first parent log
If your development history does not have fast-forward merges, i.e. the "first parent" of commits in your history are special than other parents, this option gives a better overview of the evolution of a particular branch. Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Mar 13, 2007 at 01:57 UTC
0053e902b4f777ba454b62263d3695e5292b1559
2 files changed
+12
-5
revision.c
+10
-4
@@ -350,6 +350,7 @@ static void add_parents_to_list(struct rev_info *revs, struct commit *commit, st
350
{
351
struct commit_list *parent = commit->parents;
352
unsigned left_flag;
353
+ int add, rest;
354
355
if (commit->object.flags & ADDED)
356
return;
@@ -395,18 +396,19 @@ static void add_parents_to_list(struct rev_info *revs, struct commit *commit, st
396
return;
397
398
left_flag = (commit->object.flags & SYMMETRIC_LEFT);
398
- parent = commit->parents;
399
- while (parent) {
399
+
400
+ rest = !revs->first_parent_only;
401
+ for (parent = commit->parents, add = 1; parent; add = rest) {
402
struct commit *p = parent->item;
403
404
parent = parent->next;
403
-
405
parse_commit(p);
406
p->object.flags |= left_flag;
407
if (p->object.flags & SEEN)
408
continue;
409
p->object.flags |= SEEN;
409
- insert_by_date(p, list);
410
+ if (add)
411
+ insert_by_date(p, list);
412
}
413
}
414
@@ -836,6 +838,10 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
838
handle_all(revs, flags);
839
continue;
840
}
841
+ if (!strcmp(arg, "--first-parent")) {
842
+ revs->first_parent_only = 1;
843
+ continue;
844
+ }
845
if (!strcmp(arg, "--reflog")) {
846
handle_reflog(revs, flags);
847
continue;
revision.h
+2
-1
@@ -46,7 +46,8 @@ struct rev_info {
46
boundary:2,
47
left_right:1,
48
parents:1,
49
- reverse:1;
49
+ reverse:1,
50
+ first_parent_only:1;
51
52
/* Diff flags */
53
unsigned int diff:1,