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 42fea4852..99d5d2eda 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 static DirCache read(final File indexLocation) * 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 static DirCache read(final File indexLocation) */ 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 static DirCache lock(final File indexLocation) * 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 static DirCache lock(final File indexLocation) */ 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. */