git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: jon@blackcubes.dyndns.org
To: git@vger.kernel.org
Cc: jon.seymour@gmail.com, torvalds@osdl.org
Subject: [PATCH] Factor out filtering in rev-list.c
Date: 6 Jun 2005 07:17:28 -0000	[thread overview]
Message-ID: <20050606071728.30223.qmail@blackcubes.dyndns.org> (raw)

[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;
 }			
 
 

                 reply	other threads:[~2005-06-06  7:17 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050606071728.30223.qmail@blackcubes.dyndns.org \
    --to=jon@blackcubes.dyndns.org \
    --cc=git@vger.kernel.org \
    --cc=jon.seymour@gmail.com \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).