This permits using a DirCache as a temporary storage area in memory
only, with no chance of it being written out to disk.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
.../src/org/spearce/jgit/dircache/DirCache.java | 17 +++++++++++++++++
1 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/org.spearce.jgit/src/org/spearce/jgit/dircache/DirCache.java b/org.spearce.jgit/src/org/spearce/jgit/dircache/DirCache.java
index b3c57ad..c5a4f91 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/dircache/DirCache.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/dircache/DirCache.java
@@ -111,6 +111,17 @@ static int cmp(final byte[] aPath, final int aLen, final byte[] bPath,
}
/**
+ * Create a new empty index which is never stored on disk.
+ *
+ * @return an empty cache which has no backing store file. The cache may not
+ * be read or written, but it may be queried and updated (in
+ * memory).
+ */
+ public static DirCache newInCore() {
+ return new DirCache(null);
+ }
+
+ /**
* Create a new in-core index representation and read an index from disk.
* <p>
* The new index will be read before it is returned to the caller. Read
@@ -297,6 +308,8 @@ void replace(final DirCacheEntry[] e, final int cnt) {
* library does not support.
*/
public void read() throws IOException, CorruptObjectException {
+ if (liveFile == null)
+ throw new IOException("DirCache does not have a backing file");
if (!liveFile.exists())
clear();
else if (liveFile.lastModified() != lastModified) {
@@ -407,6 +420,8 @@ private static boolean is_DIRC(final byte[] hdr) {
* hold the lock.
*/
public boolean lock() throws IOException {
+ if (liveFile == null)
+ throw new IOException("DirCache does not have a backing file");
final LockFile tmp = new LockFile(liveFile);
if (tmp.lock()) {
tmp.setNeedStatInformation(true);
@@ -515,6 +530,8 @@ public boolean commit() {
}
private void requireLocked(final LockFile tmp) {
+ if (liveFile == null)
+ throw new IllegalStateException("DirCache is not locked");
if (tmp == null)
throw new IllegalStateException("DirCache "
+ liveFile.getAbsolutePath() + " not locked.");
--
1.6.1.399.g0d272
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html| Greg KH | [GIT PATCH] driver core patches against 2.6.24 |
| Eric Sandeen | Re: [RFC] Heads up on sys_fallocate() |
| Vladislav Bolkhovitin | Re: Integration of SCST in the mainstream Linux kernel |
| Rafael J. Wysocki | [Bug #11204] Commit 76a2a6ee8a0660a29127f05989ac59ae1ce865fa breaks PXA270 (at lea... |
git: | |
| Gerrit Renker | [PATCH 34/37] dccp: Auto-load (when supported) CCID plugins for negotiation |
| Corey Minyard | [PATCH 3/3] Convert the UDP hash lock to RCU |
| David Miller | [GIT]: Networking |
| David Miller | Re: [PATCH] pkt_sched: Destroy gen estimators under rtnl_lock(). |
