void mark_edges_uninteresting(struct rev_info *revs, show_edge_fn show_edge) { struct commit_list *list; int i; for (list = revs->commits; list; list = list->next) { struct commit *commit = list->item; if (commit->object.flags & UNINTERESTING) { mark_tree_uninteresting(commit->tree); if (revs->edge_hint_aggressive && !(commit->object.flags & SHOWN)) { commit->object.flags |= SHOWN; show_edge(commit); } continue; } mark_edge_parents_uninteresting(commit, revs, show_edge); } if (revs->edge_hint_aggressive) { for (i = 0; i < revs->cmdline.nr; i++) { struct object *obj = revs->cmdline.rev[i].item; struct commit *commit = (struct commit *)obj; if (obj->type != OBJ_COMMIT || !(obj->flags & UNINTERESTING)) continue; mark_tree_uninteresting(commit->tree); if (!(obj->flags & SHOWN)) { obj->flags |= SHOWN; show_edge(commit); } } } }
void mark_edges_uninteresting(struct commit_list *list, struct rev_info *revs, show_edge_fn show_edge) { for ( ; list; list = list->next) { struct commit *commit = list->item; if (commit->object.flags & UNINTERESTING) { mark_tree_uninteresting(commit->tree); continue; } mark_edge_parents_uninteresting(commit, revs, show_edge); } }
static void mark_edge_parents_uninteresting(struct commit *commit, struct rev_info *revs, show_edge_fn show_edge) { struct commit_list *parents; for (parents = commit->parents; parents; parents = parents->next) { struct commit *parent = parents->item; if (!(parent->object.flags & UNINTERESTING)) continue; mark_tree_uninteresting(parent->tree); if (revs->edge_hint && !(parent->object.flags & SHOWN)) { parent->object.flags |= SHOWN; show_edge(parent); } } }
void mark_tree_uninteresting(struct tree *tree) { struct tree_desc desc; struct name_entry entry; struct object *obj = &tree->object; if (!tree) return; if (obj->flags & UNINTERESTING) return; obj->flags |= UNINTERESTING; if (!has_sha1_file(obj->sha1)) return; if (parse_tree(tree) < 0) die("bad tree %s", sha1_to_hex(obj->sha1)); init_tree_desc(&desc, tree->buffer, tree->size); while (tree_entry(&desc, &entry)) { switch (object_type(entry.mode)) { case OBJ_TREE: mark_tree_uninteresting(lookup_tree(entry.sha1)); break; case OBJ_BLOB: mark_blob_uninteresting(lookup_blob(entry.sha1)); break; default: /* Subproject commit - not in this repository */ break; } } /* * We don't care about the tree any more * after it has been marked uninteresting. */ free(tree->buffer); tree->buffer = NULL; }
static struct commit *handle_commit(struct rev_info *revs, struct object *object, const char *name) { unsigned long flags = object->flags; /* * Tag object? Look what it points to.. */ while (object->type == OBJ_TAG) { struct tag *tag = (struct tag *) object; if (revs->tag_objects && !(flags & UNINTERESTING)) add_pending_object(revs, object, tag->tag); if (!tag->tagged) die("bad tag"); object = parse_object(tag->tagged->sha1); if (!object) die("bad object %s", sha1_to_hex(tag->tagged->sha1)); } /* * Commit object? Just return it, we'll do all the complex * reachability crud. */ if (object->type == OBJ_COMMIT) { struct commit *commit = (struct commit *)object; if (parse_commit(commit) < 0) die("unable to parse commit %s", name); if (flags & UNINTERESTING) { commit->object.flags |= UNINTERESTING; mark_parents_uninteresting(commit); revs->limited = 1; } return commit; } /* * Tree object? Either mark it uniniteresting, or add it * to the list of objects to look at later.. */ if (object->type == OBJ_TREE) { struct tree *tree = (struct tree *)object; if (!revs->tree_objects) return NULL; if (flags & UNINTERESTING) { mark_tree_uninteresting(tree); return NULL; } add_pending_object(revs, object, ""); return NULL; } /* * Blob object? You know the drill by now.. */ if (object->type == OBJ_BLOB) { struct blob *blob = (struct blob *)object; if (!revs->blob_objects) return NULL; if (flags & UNINTERESTING) { mark_blob_uninteresting(blob); return NULL; } add_pending_object(revs, object, ""); return NULL; } die("%s is unknown object", name); }