{"thread":{"id":"844","subject":"[PATCH] Factor out filtering in rev-list.c","startedAt":"2005-06-06T07:05:29Z","lastAt":"2005-06-06T07:05:29Z","messageCount":1,"participants":["jon@blackcubes.dyndns.org"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"4639","messageId":"20050606071728.30223.qmail@blackcubes.dyndns.org","threadId":"844","inReplyTo":null,"subject":"[PATCH] Factor out filtering in rev-list.c","fromName":"","fromEmail":"jon@blackcubes.dyndns.org","sentAt":null,"receivedAt":"2005-06-06T07:05:29Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"[PATCH] Factor out filtering in rev-list.c\n\nThis patch:\n   * factors out the filtering logic in show_commit_list into filter_commit.\n   * groups calls to filter_commit and show_commit into process_commit.\n   * replaces the body of the show_commit_list while loop with a call to process_commit.\n   * fixes a compiler warning by adding a return statement to get_commit_format.\n\nThe purpose of these changes is to faciliate a future merge with Jon Seymour's --merge-order patch which\nwill pass pointer to process_commit to another module.\n\nSigned-off-by: Jon Seymour <jon.seymour@gmail.com>\n\nThis patch can also be downloaded from: http://blackcubes.dyndns.org/epoch/rev-list.patch .\n\nDiverged from 000182eacf99cde27d5916aa415921924b82972c by Linus Torvalds <torvalds@ppc970.osdl.org>\n---\ndiff --git a/rev-list.c b/rev-list.c\n--- a/rev-list.c\n+++ b/rev-list.c\n@@ -40,20 +40,48 @@ static void show_commit(struct commit *c\n \t}\n }\n \n+#define STOP     0\n+#define CONTINUE 1\n+#define DO       2\n+\n+static int filter_commit(struct commit * commit)\n+{\n+\tif (commit->object.flags & UNINTERESTING)\n+\t\treturn CONTINUE;\n+\tif (min_age != -1 && (commit->date > min_age))\n+\t\treturn CONTINUE;\n+\tif (max_age != -1 && (commit->date < max_age))\n+\t\treturn STOP;\n+\tif (max_count != -1 && !max_count--)\n+\t\treturn STOP;\n+\n+\treturn DO;\n+}\n+\n+static int process_commit(struct commit * commit)\n+{\n+\tint action=filter_commit(commit);\n+\n+\tif (action == STOP) {\n+\t\treturn STOP;\n+\t}\n+\n+\tif (action == CONTINUE) {\n+\t\treturn CONTINUE;\n+\t}\n+\n+\tshow_commit(commit);\n+\n+\treturn CONTINUE;\n+}\n+\n static void show_commit_list(struct commit_list *list)\n {\n \twhile (list) {\n \t\tstruct commit *commit = pop_most_recent_commit(&list, SEEN);\n \n-\t\tif (commit->object.flags & UNINTERESTING)\n-\t\t\tcontinue;\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\tif (process_commit(commit) == STOP)\n \t\t\tbreak;\n-\t\tif (max_count != -1 && !max_count--)\n-\t\t\tbreak;\n-\t\tshow_commit(commit);\n \t}\n }\n \n@@ -110,6 +138,8 @@ static enum cmit_fmt get_commit_format(c\n \tif (!strcmp(arg, \"=short\"))\n \t\treturn CMIT_FMT_SHORT;\n \tusage(rev_list_usage);\t\n+\n+\treturn CMIT_FMT_DEFAULT;\n }\t\t\t\n \n \n"}]}