@matheusbsbs / matheus-bagliano / commits / 2a0925be35
Fork 0

Make path-limiting be incremental when possible.

This makes git-rev-list able to do path-limiting without having to parse all of history before it starts showing the results. This makes things like "git log -- pathname" much more pleasant to use. This is actually a pretty small patch, and the biggest part of it is purely cleanups (turning the "goto next" statements into "continue"), but it's conceptually a lot bigger than it looks. What it does is that if you do a path-limited revision list, and you do _not_ ask for pseudo-parenthood information, it won't do all the path-limiting up-front, but instead do it incrementally in "get_revision()". This is an absolutely huge deal for anything like "git log -- <pathname>", but also for some things that we don't do yet - like the "find where things changed" logic I've described elsewhere, where we want to find the previous revision that changed a file. The reason I put "RFC" in the subject line is that while I've validated it various ways, like doing git-rev-list HEAD -- drivers/char/ | md5sum before-and-after on the kernel archive, it's "git-rev-list" after all. In other words, it's that really really subtle and complex central piece of software. So while I think this is important and should go in asap, I also think it should get lots of testing and eyeballs looking at the code. Btw, don't even bother testing this with the git archive. git itself is so small that parsing the whole revision history for it takes about a second even with path limiting. The thing that _really_ shows this off is doing git log drivers/ on the kernel archive, or even better, on the _historic_ kernel archive. With this change, the response is instantaneous (although seeking to the end of the result will obviously take as long as it ever did). Before this change, the command would think about the result for tens of seconds - or even minutes, in the case of the bigger old kernel archive - before starting to output the results. NOTE NOTE NOTE! Using path limiting with things like "gitk", which uses the "--parents" flag to actually generate a pseudo-history of the resulting commits won't actually see the improvement in interactivity, since that forces git-rev-list to do the whole-history thing after all. MAYBE we can fix that too at some point, but I won't promise anything. Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>

Linus Torvalds committed Mar 30, 2006 at 17:05 UTC 2a0925be3512451834ec9a3e023f4cff23c1cfb7
1 file changed +22 -23
revision.c
+22 -23
@@ -711,7 +711,13 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
711 if (revs->prune_data) {
712 diff_tree_setup_paths(revs->prune_data);
713 revs->prune_fn = try_to_simplify_commit;
714 - revs->limited = 1;
714 +
715 + /*
716 + * If we fix up parent data, we currently cannot
717 + * do that on-the-fly.
718 + */
719 + if (revs->parents)
720 + revs->limited = 1;
721 }
722
723 return left;
@@ -773,41 +779,34 @@ struct commit *get_revision(struct rev_info *revs)
779 do {
780 struct commit *commit = revs->commits->item;
781
782 + revs->commits = revs->commits->next;
783 +
784 + /*
785 + * If we haven't done the list limiting, we need to look at
786 + * the parents here
787 + */
788 + if (!revs->limited)
789 + add_parents_to_list(revs, commit, &revs->commits);
790 if (commit->object.flags & SHOWN)
777 - goto next;
791 + continue;
792 if (!(commit->object.flags & BOUNDARY) &&
793 (commit->object.flags & UNINTERESTING))
780 - goto next;
794 + continue;
795 if (revs->min_age != -1 && (commit->date > revs->min_age))
782 - goto next;
796 + continue;
797 if (revs->max_age != -1 && (commit->date < revs->max_age))
798 return NULL;
799 if (revs->no_merges &&
800 commit->parents && commit->parents->next)
787 - goto next;
801 + continue;
802 if (revs->prune_fn && revs->dense) {
803 if (!(commit->object.flags & TREECHANGE))
790 - goto next;
791 - rewrite_parents(commit);
792 - }
793 - /* More to go? */
794 - if (revs->max_count) {
795 - if (commit->object.flags & BOUNDARY) {
796 - /* this is already uninteresting,
797 - * so there is no point popping its
798 - * parents into the list.
799 - */
800 - struct commit_list *it = revs->commits;
801 - revs->commits = it->next;
802 - free(it);
803 - }
804 - else
805 - pop_most_recent_commit(&revs->commits, SEEN);
804 + continue;
805 + if (revs->parents)
806 + rewrite_parents(commit);
807 }
808 commit->object.flags |= SHOWN;
809 return commit;
809 -next:
810 - pop_most_recent_commit(&revs->commits, SEEN);
810 } while (revs->commits);
811 return NULL;
812 }