* [PATCH] Factor out filtering in rev-list.c
@ 2005-06-06 7:17 jon
0 siblings, 0 replies; only message in thread
From: jon @ 2005-06-06 7:17 UTC (permalink / raw)
To: git; +Cc: jon.seymour, torvalds
[PATCH] Factor out filtering in rev-list.c
This patch:
* factors out the filtering logic in show_commit_list into filter_commit.
* groups calls to filter_commit and show_commit into process_commit.
* replaces the body of the show_commit_list while loop with a call to process_commit.
* fixes a compiler warning by adding a return statement to get_commit_format.
The purpose of these changes is to faciliate a future merge with Jon Seymour's --merge-order patch which
will pass pointer to process_commit to another module.
Signed-off-by: Jon Seymour <jon.seymour@gmail.com>
This patch can also be downloaded from: http://blackcubes.dyndns.org/epoch/rev-list.patch .
Diverged from 000182eacf99cde27d5916aa415921924b82972c by Linus Torvalds <torvalds@ppc970.osdl.org>
---
diff --git a/rev-list.c b/rev-list.c
--- a/rev-list.c
+++ b/rev-list.c
@@ -40,20 +40,48 @@ static void show_commit(struct commit *c
}
}
+#define STOP 0
+#define CONTINUE 1
+#define DO 2
+
+static int filter_commit(struct commit * commit)
+{
+ if (commit->object.flags & UNINTERESTING)
+ return CONTINUE;
+ if (min_age != -1 && (commit->date > min_age))
+ return CONTINUE;
+ if (max_age != -1 && (commit->date < max_age))
+ return STOP;
+ if (max_count != -1 && !max_count--)
+ return STOP;
+
+ return DO;
+}
+
+static int process_commit(struct commit * commit)
+{
+ int action=filter_commit(commit);
+
+ if (action == STOP) {
+ return STOP;
+ }
+
+ if (action == CONTINUE) {
+ return CONTINUE;
+ }
+
+ show_commit(commit);
+
+ return CONTINUE;
+}
+
static void show_commit_list(struct commit_list *list)
{
while (list) {
struct commit *commit = pop_most_recent_commit(&list, SEEN);
- if (commit->object.flags & UNINTERESTING)
- continue;
- if (min_age != -1 && (commit->date > min_age))
- continue;
- if (max_age != -1 && (commit->date < max_age))
+ if (process_commit(commit) == STOP)
break;
- if (max_count != -1 && !max_count--)
- break;
- show_commit(commit);
}
}
@@ -110,6 +138,8 @@ static enum cmit_fmt get_commit_format(c
if (!strcmp(arg, "=short"))
return CMIT_FMT_SHORT;
usage(rev_list_usage);
+
+ return CMIT_FMT_DEFAULT;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2005-06-06 7:17 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-06 7:17 [PATCH] Factor out filtering in rev-list.c jon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).