static int limit_list(struct rev_info *revs) { int slop = SLOP; unsigned long date = ~0ul; struct commit_list *list = revs->commits; struct commit_list *newlist = NULL; struct commit_list **p = &newlist; while (list) { struct commit_list *entry = list; struct commit *commit = list->item; struct object *obj = &commit->object; show_early_output_fn_t show; list = list->next; free(entry); if (revs->max_age != -1 && (commit->date < revs->max_age)) obj->flags |= UNINTERESTING; if (add_parents_to_list(revs, commit, &list, NULL) < 0) return -1; if (obj->flags & UNINTERESTING) { mark_parents_uninteresting(commit); if (revs->show_all) p = &commit_list_insert(commit, p)->next; slop = still_interesting(list, date, slop); if (slop) continue; /* If showing all, add the whole pending list to the end */ if (revs->show_all) *p = list; break; } if (revs->min_age != -1 && (commit->date > revs->min_age)) continue; date = commit->date; p = &commit_list_insert(commit, p)->next; show = show_early_output; if (!show) continue; show(revs, newlist); show_early_output = NULL; } if (revs->cherry_pick) cherry_pick_list(newlist, revs); revs->commits = newlist; return 0; }
static enum rewrite_result rewrite_one(struct rev_info *revs, struct commit **pp) { struct commit_list *cache = NULL; for (;;) { struct commit *p = *pp; if (!revs->limited) if (add_parents_to_list(revs, p, &revs->commits, &cache) < 0) return rewrite_one_error; if (p->parents && p->parents->next) return rewrite_one_ok; if (p->object.flags & UNINTERESTING) return rewrite_one_ok; if (!(p->object.flags & TREESAME)) return rewrite_one_ok; if (!p->parents) return rewrite_one_noparents; *pp = p->parents->item; } }
static struct commit *get_revision_1(struct rev_info *revs) { if (!revs->commits) return NULL; do { struct commit_list *entry = revs->commits; struct commit *commit = entry->item; revs->commits = entry->next; free(entry); if (revs->reflog_info) fake_reflog_parent(revs->reflog_info, commit); /* * If we haven't done the list limiting, we need to look at * the parents here. We also need to do the date-based limiting * that we'd otherwise have done in limit_list(). */ if (!revs->limited) { if (revs->max_age != -1 && (commit->date < revs->max_age)) continue; if (add_parents_to_list(revs, commit, &revs->commits, NULL) < 0) die("Failed to traverse parents of commit %s", sha1_to_hex(commit->object.sha1)); } switch (simplify_commit(revs, commit)) { case commit_ignore: continue; case commit_error: die("Failed to simplify parents of commit %s", sha1_to_hex(commit->object.sha1)); default: return commit; } } while (revs->commits); return NULL; }