summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2010-06-25 17:32:12 -0700
committerShawn O. Pearce <spearce@spearce.org>2010-06-25 17:46:39 -0700
commit553c2e5a42061d216637aca882b6c216e21aaf1a (patch)
tree02b00a687f382399d10278a2fba680ea9856053e
parent60aae90d4d15d6b35d19941867dad966ddcbe161 (diff)
downloadjgit-553c2e5a42061d216637aca882b6c216e21aaf1a.tar.gz
jgit-553c2e5a42061d216637aca882b6c216e21aaf1a.zip
DirCache must use getIndexFile
When reading or locking the index of a repository, we need to use the index file specified by the repository, to ensure we correctly honor what the repository was configured with. Change-Id: I5be366ce32d7923b888dc01d19335912b01b7c4c Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java8
1 files changed, 6 insertions, 2 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java
index 42fea48520..99d5d2eda4 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java
@@ -168,6 +168,8 @@ public class DirCache {
* repository the caller wants to read the default index of.
* @return a cache representing the contents of the specified index file (if
* it exists) or an empty cache if the file does not exist.
+ * @throws IllegalStateException
+ * if the repository is bare (lacks a working directory).
* @throws IOException
* the index file is present but could not be read.
* @throws CorruptObjectException
@@ -176,7 +178,7 @@ public class DirCache {
*/
public static DirCache read(final Repository db)
throws CorruptObjectException, IOException {
- return read(new File(db.getDirectory(), "index"));
+ return read(db.getIndexFile());
}
/**
@@ -231,6 +233,8 @@ public class DirCache {
* repository the caller wants to read the default index of.
* @return a cache representing the contents of the specified index file (if
* it exists) or an empty cache if the file does not exist.
+ * @throws IllegalStateException
+ * if the repository is bare (lacks a working directory).
* @throws IOException
* the index file is present but could not be read, or the lock
* could not be obtained.
@@ -240,7 +244,7 @@ public class DirCache {
*/
public static DirCache lock(final Repository db)
throws CorruptObjectException, IOException {
- return lock(new File(db.getDirectory(), "index"));
+ return lock(db.getIndexFile());
}
/** Location of the current version of the index file. */