X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=revision.c;h=2a33637f62878f225c4eb74fbbd2ed5272cc36bb;hb=aa1dbc9897822c8acb284b35c40da60f3debca91;hp=48858714250da8e7328c132f60dfcd076d103433;hpb=3bddd7dbba2f178e7fab5916522bf398eb55ffc0;p=git.git diff --git a/revision.c b/revision.c index 48858714..2a33637f 100644 --- a/revision.c +++ b/revision.c @@ -482,6 +482,21 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch revs->max_count = atoi(arg + 12); continue; } + /* accept -, like traditilnal "head" */ + if ((*arg == '-') && isdigit(arg[1])) { + revs->max_count = atoi(arg + 1); + continue; + } + if (!strcmp(arg, "-n")) { + if (argc <= i + 1) + die("-n requires an argument"); + revs->max_count = atoi(argv[++i]); + continue; + } + if (!strncmp(arg,"-n",2)) { + revs->max_count = atoi(arg + 2); + continue; + } if (!strncmp(arg, "--max-age=", 10)) { revs->max_age = atoi(arg + 10); revs->limited = 1; @@ -669,13 +684,11 @@ static void rewrite_parents(struct commit *commit) struct commit *get_revision(struct rev_info *revs) { struct commit_list *list = revs->commits; - struct commit *commit; if (!list) return NULL; /* Check the max_count ... */ - commit = list->item; switch (revs->max_count) { case -1: break; @@ -686,22 +699,28 @@ struct commit *get_revision(struct rev_info *revs) } do { - commit = pop_most_recent_commit(&revs->commits, SEEN); + struct commit *commit = revs->commits->item; + if (commit->object.flags & (UNINTERESTING|SHOWN)) - continue; + goto next; if (revs->min_age != -1 && (commit->date > revs->min_age)) - continue; + goto next; if (revs->max_age != -1 && (commit->date < revs->max_age)) return NULL; if (revs->no_merges && commit->parents && commit->parents->next) - continue; + goto next; if (revs->paths && revs->dense) { if (!(commit->object.flags & TREECHANGE)) - continue; + goto next; rewrite_parents(commit); } + /* More to go? */ + if (revs->max_count) + pop_most_recent_commit(&revs->commits, SEEN); commit->object.flags |= SHOWN; return commit; +next: + pop_most_recent_commit(&revs->commits, SEEN); } while (revs->commits); return NULL; }