git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[EGIT PATCH1/2] fix-CommitTimeRevFilter-by-adding-a-Between-filter

From
Mark Struberg <struberg@yahoo.de>
Date
Jun 15, 2009, 21:35 UTC
Message-ID
<79030.47302.qm@web27808.mail.ukl.yahoo.com>
>From 0a5e2d469972791cdc2e1db00602142980050af8 Mon Sep 17 00:00:00 2001
From: Mark Struberg <struberg@yahoo.de>
Date: Mon, 15 Jun 2009 01:25:25 +0200
Subject: [PATCH] fix CommitTimeRevFilter by adding a Between filter subclass
---
 .../jgit/revwalk/filter/CommitTimeRevFilter.java   |   29 ++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)
diff --git a/org.spearce.jgit/src/org/spearce/jgit/revwalk/filter/CommitTimeRevFilter.java b/org.spearce.jgit/src/org/spearce/jgit/revwalk/filter/CommitTimeRevFilter.java
index a3751b8..0aaa78d 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/revwalk/filter/CommitTimeRevFilter.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/revwalk/filter/CommitTimeRevFilter.java
@@ -70,6 +70,18 @@ public static final RevFilter after(final Date ts) {
 		return new After(ts.getTime());
 	}
 
+	/**
+	 * Create a new filter to select commits after or equal a given date/time <code>since</code> 
+	 * and before or equal a given date/time <code>until</code>.
+	 * 
+	 * @param since the point in time to cut on.
+	 * @param until the point in time to cut off.
+	 * @return a new filter to select commits between the given date/times.
+	 */
+	public static final RevFilter between(final Date since, final Date until) {
+		return new Between(since.getTime(), until.getTime());
+	}
+
 	final int when;
 
 	CommitTimeRevFilter(final long ts) {
@@ -117,4 +129,21 @@ public boolean include(final RevWalk walker, final RevCommit cmit)
 			return true;
 		}
 	}
+
+	private static class Between extends CommitTimeRevFilter {
+		private final int until;
+
+		Between(final long since, final long until) {
+			super(since);
+			this.until = (int) (until / 1000); 
+		}
+
+		@Override
+		public boolean include(final RevWalk walker, final RevCommit cmit)
+				throws StopWalkException, MissingObjectException,
+				IncorrectObjectTypeException, IOException {
+			return cmit.getCommitTime() <= until && cmit.getCommitTime() >= when;
+		}
+	}
+
 }
-- 
1.6.0.6



      
Message 1 of 1 in “[EGIT PATCH1/2] fix-CommitTimeRevFilter-by-adding-a-Between-filter”
  1. Mark StrubergJun 15, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.