{"thread":{"id":"3835","subject":"Make \"--parents\" logs also be incremental","startedAt":"2006-04-09T00:05:58Z","lastAt":"2006-04-09T00:05:58Z","messageCount":1,"participants":["Linus Torvalds"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"18487","messageId":"Pine.LNX.4.64.0604081658110.9504@g5.osdl.org","threadId":"3835","inReplyTo":null,"subject":"Make \"--parents\" logs also be incremental","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2006-04-09T00:05:58Z","receivedAt":"2006-04-09T00:05:58Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\nThe parent rewriting feature caused us to create the whole history in one \ngo, and then simplify it later, because of how rewrite_parents() had been \nwritten. However, with a little tweaking, it's perfectly possible to do \neven that one incrementally.\n\nRight now, this doesn't really much matter, because every user of \n\"--parents\" will probably generally _also_ use \"--topo-order\", which will \ncause the old non-incremental behaviour anyway. However, I'm hopeful that \nwe could make even the topological sort incremental, or at least \n_partially_ so (for example, make it incremental up to the first merge).\n\nIn the meantime, this at least moves things in the right direction, and \nremoves a strange special case.\n\nSigned-off-by: Linus Torvalds <torvalds@osdl.org>\n---\ndiff --git a/http-push.c b/http-push.c\nindex b60fa8d..57cefde 100644\n--- a/http-push.c\n+++ b/http-push.c\n@@ -59,12 +59,12 @@ #define LOCK_REQUEST \"<?xml version=\\\"1.\n #define LOCK_TIME 600\n #define LOCK_REFRESH 30\n \n-/* bits #0-4 in revision.h */\n+/* bits #0-6 in revision.h */\n \n-#define LOCAL    (1u << 5)\n-#define REMOTE   (1u << 6)\n-#define FETCHING (1u << 7)\n-#define PUSHING  (1u << 8)\n+#define LOCAL    (1u << 7)\n+#define REMOTE   (1u << 8)\n+#define FETCHING (1u << 9)\n+#define PUSHING  (1u << 10)\n \n /* We allow \"recursive\" symbolic refs. Only within reason, though */\n #define MAXDEPTH 5\ndiff --git a/rev-list.c b/rev-list.c\nindex 1301502..359195b 100644\n--- a/rev-list.c\n+++ b/rev-list.c\n@@ -7,9 +7,9 @@ #include \"blob.h\"\n #include \"tree-walk.h\"\n #include \"revision.h\"\n \n-/* bits #0-5 in revision.h */\n+/* bits #0-6 in revision.h */\n \n-#define COUNTED\t\t(1u<<6)\n+#define COUNTED\t\t(1u<<7)\n \n static const char rev_list_usage[] =\n \"git-rev-list [OPTION] <commit-id>... [ -- paths... ]\\n\"\ndiff --git a/revision.c b/revision.c\nindex ce35b5a..fe26562 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -340,6 +340,10 @@ static void add_parents_to_list(struct r\n {\n \tstruct commit_list *parent = commit->parents;\n \n+\tif (commit->object.flags & ADDED)\n+\t\treturn;\n+\tcommit->object.flags |= ADDED;\n+\n \t/*\n \t * If the commit is uninteresting, don't try to\n \t * prune parents - we want the maximal uninteresting\n@@ -705,13 +709,6 @@ int setup_revisions(int argc, const char\n \tif (revs->prune_data) {\n \t\tdiff_tree_setup_paths(revs->prune_data);\n \t\trevs->prune_fn = try_to_simplify_commit;\n-\n-\t\t/*\n-\t\t * If we fix up parent data, we currently cannot\n-\t\t * do that on-the-fly.\n-\t\t */\n-\t\tif (revs->parents)\n-\t\t\trevs->limited = 1;\n \t}\n \n \treturn left;\n@@ -728,10 +725,12 @@ void prepare_revision_walk(struct rev_in\n \t\t\t\t\t     revs->topo_getter);\n }\n \n-static int rewrite_one(struct commit **pp)\n+static int rewrite_one(struct rev_info *revs, struct commit **pp)\n {\n \tfor (;;) {\n \t\tstruct commit *p = *pp;\n+\t\tif (!revs->limited)\n+\t\t\tadd_parents_to_list(revs, p, &revs->commits);\n \t\tif (p->object.flags & (TREECHANGE | UNINTERESTING))\n \t\t\treturn 0;\n \t\tif (!p->parents)\n@@ -740,12 +739,12 @@ static int rewrite_one(struct commit **p\n \t}\n }\n \n-static void rewrite_parents(struct commit *commit)\n+static void rewrite_parents(struct rev_info *revs, struct commit *commit)\n {\n \tstruct commit_list **pp = &commit->parents;\n \twhile (*pp) {\n \t\tstruct commit_list *parent = *pp;\n-\t\tif (rewrite_one(&parent->item) < 0) {\n+\t\tif (rewrite_one(revs, &parent->item) < 0) {\n \t\t\t*pp = parent->next;\n \t\t\tcontinue;\n \t\t}\n@@ -802,7 +801,7 @@ struct commit *get_revision(struct rev_i\n \t\t\tif (!(commit->object.flags & TREECHANGE))\n \t\t\t\tcontinue;\n \t\t\tif (revs->parents)\n-\t\t\t\trewrite_parents(commit);\n+\t\t\t\trewrite_parents(revs, commit);\n \t\t}\n \t\tcommit->object.flags |= SHOWN;\n \t\treturn commit;\ndiff --git a/revision.h b/revision.h\nindex 0caeecf..83d28d5 100644\n--- a/revision.h\n+++ b/revision.h\n@@ -7,6 +7,7 @@ #define TREECHANGE\t(1u<<2)\n #define SHOWN\t\t(1u<<3)\n #define TMP_MARK\t(1u<<4) /* for isolated cases; clean after use */\n #define BOUNDARY\t(1u<<5)\n+#define ADDED\t\t(1u<<6)\t/* Parents already parsed and added? */\n \n struct rev_info;\n \n"}]}