Skip to content

Commit 3381c79

Browse files
Linus TorvaldsJunio C Hamano
authored andcommitted
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>
1 parent 0ed49a3 commit 3381c79

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

http-push.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@ enum XML_Status {
5959
#define LOCK_TIME 600
6060
#define LOCK_REFRESH 30
6161

62-
/* bits #0-4 in revision.h */
62+
/* bits #0-6 in revision.h */
6363

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)
6868

6969
/* We allow "recursive" symbolic refs. Only within reason, though */
7070
#define MAXDEPTH 5

rev-list.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
#include "tree-walk.h"
88
#include "revision.h"
99

10-
/* bits #0-5 in revision.h */
10+
/* bits #0-6 in revision.h */
1111

12-
#define COUNTED (1u<<6)
12+
#define COUNTED (1u<<7)
1313

1414
static const char rev_list_usage[] =
1515
"git-rev-list [OPTION] <commit-id>... [ -- paths... ]\n"

revision.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,10 @@ static void add_parents_to_list(struct rev_info *revs, struct commit *commit, st
340340
{
341341
struct commit_list *parent = commit->parents;
342342

343+
if (commit->object.flags & ADDED)
344+
return;
345+
commit->object.flags |= ADDED;
346+
343347
/*
344348
* If the commit is uninteresting, don't try to
345349
* 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
705709
if (revs->prune_data) {
706710
diff_tree_setup_paths(revs->prune_data);
707711
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;
715712
}
716713

717714
return left;
@@ -728,10 +725,12 @@ void prepare_revision_walk(struct rev_info *revs)
728725
revs->topo_getter);
729726
}
730727

731-
static int rewrite_one(struct commit **pp)
728+
static int rewrite_one(struct rev_info *revs, struct commit **pp)
732729
{
733730
for (;;) {
734731
struct commit *p = *pp;
732+
if (!revs->limited)
733+
add_parents_to_list(revs, p, &revs->commits);
735734
if (p->object.flags & (TREECHANGE | UNINTERESTING))
736735
return 0;
737736
if (!p->parents)
@@ -740,12 +739,12 @@ static int rewrite_one(struct commit **pp)
740739
}
741740
}
742741

743-
static void rewrite_parents(struct commit *commit)
742+
static void rewrite_parents(struct rev_info *revs, struct commit *commit)
744743
{
745744
struct commit_list **pp = &commit->parents;
746745
while (*pp) {
747746
struct commit_list *parent = *pp;
748-
if (rewrite_one(&parent->item) < 0) {
747+
if (rewrite_one(revs, &parent->item) < 0) {
749748
*pp = parent->next;
750749
continue;
751750
}
@@ -802,7 +801,7 @@ struct commit *get_revision(struct rev_info *revs)
802801
if (!(commit->object.flags & TREECHANGE))
803802
continue;
804803
if (revs->parents)
805-
rewrite_parents(commit);
804+
rewrite_parents(revs, commit);
806805
}
807806
commit->object.flags |= SHOWN;
808807
return commit;

revision.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#define SHOWN (1u<<3)
88
#define TMP_MARK (1u<<4) /* for isolated cases; clean after use */
99
#define BOUNDARY (1u<<5)
10+
#define ADDED (1u<<6) /* Parents already parsed and added? */
1011

1112
struct rev_info;
1213

0 commit comments

Comments
 (0)