{"thread":{"id":"472","subject":"[PATCH] control/limit output of git-rev-list","startedAt":"2005-05-04T11:58:14Z","lastAt":"2005-05-04T11:58:14Z","messageCount":1,"participants":["Kay Sievers"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"2567","messageId":"20050504115814.GA18946@vrfy.org","threadId":"472","inReplyTo":null,"subject":"[PATCH] control/limit output of git-rev-list","fromName":"Kay Sievers","fromEmail":"kay.sievers@vrfy.org","sentAt":"2005-05-04T11:58:14Z","receivedAt":"2005-05-04T11:58:14Z","isPatch":true,"sender":{"key":"kay.sievers@vrfy.org","avatar":null},"body":"gitweb.cgi's default view is the log of the last day and git-rev-list\ncan stop crawling the whole repo if we have all our data to display in the\nbrowser. Also the rss-feed query needs only the last 20 items. This\nwill speeds up these queries dramatically.\n\n  usage: rev-list [OPTION] commit-id\n    --max-count=nr\n    --max-age=epoch\n    --min-age=epoch\n\nSigned-off-by: Kay Sievers <kay.sievers@vrfy.org>\n---\n\nPasky, kernel.org uses the cogito binaries. It would be nice, if you can\ninclude this into the next release, so we can safe these boxes a whole lot\nof useless work.\n\nThanks,\nKay\n\n--- a/rev-list.c\n+++ b/rev-list.c\n@@ -6,9 +6,31 @@ int main(int argc, char **argv)\n \tunsigned char sha1[20];\n \tstruct commit_list *list = NULL;\n \tstruct commit *commit;\n+\tchar *commit_arg = NULL;\n+\tint i;\n+\tunsigned long max_age = -1;\n+\tunsigned long min_age = -1;\n+\tint max_count = -1;\n \n-\tif (argc != 2 || get_sha1(argv[1], sha1))\n-\t\tusage(\"rev-list <commit-id>\");\n+\tfor (i = 1 ; i < argc; i++) {\n+\t\tchar *arg = argv[i];\n+\n+\t\tif (!strncmp(arg, \"--max-count=\", 12)) {\n+\t\t\tmax_count = atoi(arg + 12);\n+\t\t} else if (!strncmp(arg, \"--max-age=\", 10)) {\n+\t\t\tmax_age = atoi(arg + 10);\n+\t\t} else if (!strncmp(arg, \"--min-age=\", 10)) {\n+\t\t\tmin_age = atoi(arg + 10);\n+\t\t} else {\n+\t\t\tcommit_arg = arg;\n+\t\t}\n+\t}\n+\n+\tif (!commit_arg || get_sha1(commit_arg, sha1))\n+\t\tusage(\"usage: rev-list [OPTION] commit-id\\n\"\n+\t\t      \"  --max-count=nr\\n\"\n+\t\t      \"  --max-age=epoch\\n\"\n+\t\t      \"  --min-age=epoch\\n\");\n \n \tcommit = lookup_commit(sha1);\n \tif (!commit || parse_commit(commit) < 0)\n@@ -17,6 +39,13 @@ int main(int argc, char **argv)\n \tcommit_list_insert(commit, &list);\n \tdo {\n \t\tstruct commit *commit = pop_most_recent_commit(&list, 0x1);\n+\n+\t\tif (min_age != -1 && (commit->date > min_age))\n+\t\t\tcontinue;\n+\t\tif (max_age != -1 && (commit->date < max_age))\n+\t\t\tbreak;\n+\t\tif (max_count != -1 && !max_count--)\n+\t\t\tbreak;\n \t\tprintf(\"%s\\n\", sha1_to_hex(commit->object.sha1));\n \t} while (list);\n \treturn 0;\n\n"}]}