From: "Shawn O. Pearce" <spearce@spearce.org>
To: Robin Rosenberg <robin.rosenberg@dewire.com>,
Marek Zawirski <marek.zawirski@gmail.com>
Cc: git@vger.kernel.org
Subject: [EGIT PATCH 07/11] Allow WorkingTreeIterator to track last modified time for entries
Date: Sun, 10 Aug 2008 01:46:22 -0700 [thread overview]
Message-ID: <1218357986-19671-8-git-send-email-spearce@spearce.org> (raw)
In-Reply-To: <1218357986-19671-7-git-send-email-spearce@spearce.org>
We need this last modified time to compare against the index to decide
if a file is dirty or not. Its computed on demand only for the items
we actually care about, as we don't need the last modified time for a
directory.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
.../spearce/jgit/treewalk/FileTreeIterator.java | 9 +++++++++
.../spearce/jgit/treewalk/WorkingTreeIterator.java | 13 +++++++++++++
2 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/org.spearce.jgit/src/org/spearce/jgit/treewalk/FileTreeIterator.java b/org.spearce.jgit/src/org/spearce/jgit/treewalk/FileTreeIterator.java
index 331f153..25425dd 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/treewalk/FileTreeIterator.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/treewalk/FileTreeIterator.java
@@ -106,6 +106,8 @@ public class FileTreeIterator extends WorkingTreeIterator {
private long length = -1;
+ private long lastModified;
+
FileEntry(final File f) {
file = f;
@@ -138,6 +140,13 @@ public class FileTreeIterator extends WorkingTreeIterator {
}
@Override
+ public long getLastModified() {
+ if (lastModified == 0)
+ lastModified = file.lastModified();
+ return lastModified;
+ }
+
+ @Override
public InputStream openInputStream() throws IOException {
return new FileInputStream(file);
}
diff --git a/org.spearce.jgit/src/org/spearce/jgit/treewalk/WorkingTreeIterator.java b/org.spearce.jgit/src/org/spearce/jgit/treewalk/WorkingTreeIterator.java
index afac77b..cb4a089 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/treewalk/WorkingTreeIterator.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/treewalk/WorkingTreeIterator.java
@@ -433,6 +433,19 @@ public abstract class WorkingTreeIterator extends AbstractTreeIterator {
public abstract long getLength();
/**
+ * Get the last modified time of this entry.
+ * <p>
+ * <b>Note: Efficient implementation required.</b>
+ * <p>
+ * The implementation of this method must be efficient. If a subclass
+ * needs to compute the value they should cache the reference within an
+ * instance member instead.
+ *
+ * @return time since the epoch (in ms) of the last change.
+ */
+ public abstract long getLastModified();
+
+ /**
* Get the name of this entry within its directory.
* <p>
* Efficient implementations are not required. The caller will obtain
--
1.6.0.rc2.219.g1250ab
next prev parent reply other threads:[~2008-08-10 8:47 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-10 8:46 [EGIT PATCH 00/11] Misc. cleanups and improvements Shawn O. Pearce
2008-08-10 8:46 ` [EGIT PATCH 01/11] Fix RawParseUtils.endOfParagraph to work on all corner cases Shawn O. Pearce
2008-08-10 8:46 ` [EGIT PATCH 02/11] Add test case for the RevCommit parsing code Shawn O. Pearce
2008-08-10 8:46 ` [EGIT PATCH 03/11] Notify AbstractTreeIterator implementations of skipped tree entries Shawn O. Pearce
2008-08-10 8:46 ` [EGIT PATCH 04/11] Allow AbstractTreeIterator subclasses to supply their own path array Shawn O. Pearce
2008-08-10 8:46 ` [EGIT PATCH 05/11] Allow WorkingTreeIterators to define their prefix path when created Shawn O. Pearce
2008-08-10 8:46 ` [EGIT PATCH 06/11] Add getTree to TreeWalk for locating the current iterator instance Shawn O. Pearce
2008-08-10 8:46 ` Shawn O. Pearce [this message]
2008-08-10 8:46 ` [EGIT PATCH 08/11] Expose the current entry's length, last modified in WorkingTreeIterator Shawn O. Pearce
2008-08-10 8:46 ` [EGIT PATCH 09/11] Expose idBuffer,idOffset in AbstractTreeIterator to applications Shawn O. Pearce
2008-08-10 8:46 ` [EGIT PATCH 10/11] Add a TreeWalk iterator implementation for IContainer Shawn O. Pearce
2008-08-10 8:46 ` [EGIT PATCH 11/11] Teach NB how to encode/decode an unsigned 16 bit integer Shawn O. Pearce
2008-08-13 20:41 ` [EGIT PATCH 10/11] Add a TreeWalk iterator implementation for IContainer Robin Rosenberg
2008-08-14 4:19 ` Shawn O. Pearce
2008-08-14 5:20 ` Robin Rosenberg
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=1218357986-19671-8-git-send-email-spearce@spearce.org \
--to=spearce@spearce.org \
--cc=git@vger.kernel.org \
--cc=marek.zawirski@gmail.com \
--cc=robin.rosenberg@dewire.com \
/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).