@matheusbsbs / matheus-bagliano / commits / 3381c790e5
Fork 0

Make "--parents" logs also be incremental

The parent rewriting feature caused us to create the whole history in one go, and then simplify it later, because of how rewrite_parents() had been written. However, with a little tweaking, it's perfectly possible to do even that one incrementally. Right now, this doesn't really much matter, because every user of "--parents" will probably generally _also_ use "--topo-order", which will cause the old non-incremental behaviour anyway. However, I'm hopeful that we could make even the topological sort incremental, or at least _partially_ so (for example, make it incremental up to the first merge). In the meantime, this at least moves things in the right direction, and removes a strange special case. Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>

Linus Torvalds committed Apr 8, 2006 at 17:05 UTC 3381c790e5ca04326d26e1dd9ff482961c6e425b
4 files changed +18 -18
http-push.c
+5 -5
@@ -59,12 +59,12 @@ enum XML_Status {
59 #define LOCK_TIME 600
60 #define LOCK_REFRESH 30
61
62 -/* bits #0-4 in revision.h */
62 +/* bits #0-6 in revision.h */
63
64 -#define LOCAL (1u << 5)
65 -#define REMOTE (1u << 6)
66 -#define FETCHING (1u << 7)
67 -#define PUSHING (1u << 8)
64 +#define LOCAL (1u << 7)
65 +#define REMOTE (1u << 8)
66 +#define FETCHING (1u << 9)
67 +#define PUSHING (1u << 10)
68
69 /* We allow "recursive" symbolic refs. Only within reason, though */
70 #define MAXDEPTH 5
rev-list.c
+2 -2
@@ -7,9 +7,9 @@
7 #include "tree-walk.h"
8 #include "revision.h"
9
10 -/* bits #0-5 in revision.h */
10 +/* bits #0-6 in revision.h */
11
12 -#define COUNTED (1u<<6)
12 +#define COUNTED (1u<<7)
13
14 static const char rev_list_usage[] =
15 "git-rev-list [OPTION] <commit-id>... [ -- paths... ]\n"
revision.c
+10 -11
@@ -340,6 +340,10 @@ static void add_parents_to_list(struct rev_info *revs, struct commit *commit, st
340 {
341 struct commit_list *parent = commit->parents;
342
343 + if (commit->object.flags & ADDED)
344 + return;
345 + commit->object.flags |= ADDED;
346 +
347 /*
348 * If the commit is uninteresting, don't try to
349 * prune parents - we want the maximal uninteresting
@@ -705,13 +709,6 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
709 if (revs->prune_data) {
710 diff_tree_setup_paths(revs->prune_data);
711 revs->prune_fn = try_to_simplify_commit;
708 -
709 - /*
710 - * If we fix up parent data, we currently cannot
711 - * do that on-the-fly.
712 - */
713 - if (revs->parents)
714 - revs->limited = 1;
712 }
713
714 return left;
@@ -728,10 +725,12 @@ void prepare_revision_walk(struct rev_info *revs)
725 revs->topo_getter);
726 }
727
731 -static int rewrite_one(struct commit **pp)
728 +static int rewrite_one(struct rev_info *revs, struct commit **pp)
729 {
730 for (;;) {
731 struct commit *p = *pp;
732 + if (!revs->limited)
733 + add_parents_to_list(revs, p, &revs->commits);
734 if (p->object.flags & (TREECHANGE | UNINTERESTING))
735 return 0;
736 if (!p->parents)
@@ -740,12 +739,12 @@ static int rewrite_one(struct commit **pp)
739 }
740 }
741
743 -static void rewrite_parents(struct commit *commit)
742 +static void rewrite_parents(struct rev_info *revs, struct commit *commit)
743 {
744 struct commit_list **pp = &commit->parents;
745 while (*pp) {
746 struct commit_list *parent = *pp;
748 - if (rewrite_one(&parent->item) < 0) {
747 + if (rewrite_one(revs, &parent->item) < 0) {
748 *pp = parent->next;
749 continue;
750 }
@@ -802,7 +801,7 @@ struct commit *get_revision(struct rev_info *revs)
801 if (!(commit->object.flags & TREECHANGE))
802 continue;
803 if (revs->parents)
805 - rewrite_parents(commit);
804 + rewrite_parents(revs, commit);
805 }
806 commit->object.flags |= SHOWN;
807 return commit;
revision.h
+1
@@ -7,6 +7,7 @@
7 #define SHOWN (1u<<3)
8 #define TMP_MARK (1u<<4) /* for isolated cases; clean after use */
9 #define BOUNDARY (1u<<5)
10 +#define ADDED (1u<<6) /* Parents already parsed and added? */
11
12 struct rev_info;
13