static int prepare_walk(git_revwalk *walk) { int error; git_commit_list *list; git_commit_list_node *next; /* If there were no pushes, we know that the walk is already over */ if (!walk->did_push) { giterr_clear(); return GIT_ITEROVER; } if (walk->did_hide && (error = premark_uninteresting(walk)) < 0) return error; for (list = walk->user_input; list; list = list->next) { if (process_commit(walk, list->item, list->item->uninteresting) < 0) return -1; } if (walk->sorting & GIT_SORT_TOPOLOGICAL) { unsigned short i; while ((error = walk->get_next(&next, walk)) == 0) { for (i = 0; i < next->out_degree; ++i) { git_commit_list_node *parent = next->parents[i]; parent->in_degree++; } if (git_commit_list_insert(next, &walk->iterator_topo) == NULL) return -1; } if (error != GIT_ITEROVER) return error; walk->get_next = &revwalk_next_toposort; } if (walk->sorting & GIT_SORT_REVERSE) { while ((error = walk->get_next(&next, walk)) == 0) if (git_commit_list_insert(next, &walk->iterator_reverse) == NULL) return -1; if (error != GIT_ITEROVER) return error; walk->get_next = &revwalk_next_reverse; } walk->walking = 1; return 0; }
static int process_commit_parents(git_revwalk *walk, commit_object *commit) { unsigned short i; int error = GIT_SUCCESS; for (i = 0; i < commit->out_degree && error == GIT_SUCCESS; ++i) { error = process_commit(walk, commit->parents[i]); } return error; }
static int push_commit(git_revwalk *walk, const git_oid *oid, int uninteresting) { commit_object *commit; commit = commit_lookup(walk, oid); if (commit == NULL) return GIT_ENOTFOUND; commit->uninteresting = uninteresting; return process_commit(walk, commit); }
static int process_commit_parents(git_revwalk *walk, git_commit_list_node *commit) { unsigned short i, max; int error = 0; max = commit->out_degree; if (walk->first_parent && commit->out_degree) max = 1; for (i = 0; i < max && !error; ++i) error = process_commit(walk, commit->parents[i], commit->uninteresting); return error; }
static int process_object(struct walker *walker, struct object *obj) { if (obj->type == OBJ_COMMIT) { if (process_commit(walker, (struct commit *)obj)) return -1; return 0; } if (obj->type == OBJ_TREE) { if (process_tree(walker, (struct tree *)obj)) return -1; return 0; } if (obj->type == OBJ_BLOB) { return 0; } if (obj->type == OBJ_TAG) { if (process_tag(walker, (struct tag *)obj)) return -1; return 0; } return error("Unable to determine requirements " "of type %s for %s", typename(obj->type), sha1_to_hex(obj->sha1)); }