Browse Source

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>
stable-0.9
Shawn O. Pearce 15 years ago
parent
commit
553c2e5a42
  1. 8
      org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java

8
org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCache.java vendored

@ -168,6 +168,8 @@ public class DirCache {
* repository the caller wants to read the default index of. * repository the caller wants to read the default index of.
* @return a cache representing the contents of the specified index file (if * @return a cache representing the contents of the specified index file (if
* it exists) or an empty cache if the file does not exist. * 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 * @throws IOException
* the index file is present but could not be read. * the index file is present but could not be read.
* @throws CorruptObjectException * @throws CorruptObjectException
@ -176,7 +178,7 @@ public class DirCache {
*/ */
public static DirCache read(final Repository db) public static DirCache read(final Repository db)
throws CorruptObjectException, IOException { 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. * repository the caller wants to read the default index of.
* @return a cache representing the contents of the specified index file (if * @return a cache representing the contents of the specified index file (if
* it exists) or an empty cache if the file does not exist. * 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 * @throws IOException
* the index file is present but could not be read, or the lock * the index file is present but could not be read, or the lock
* could not be obtained. * could not be obtained.
@ -240,7 +244,7 @@ public class DirCache {
*/ */
public static DirCache lock(final Repository db) public static DirCache lock(final Repository db)
throws CorruptObjectException, IOException { throws CorruptObjectException, IOException {
return lock(new File(db.getDirectory(), "index")); return lock(db.getIndexFile());
} }
/** Location of the current version of the index file. */ /** Location of the current version of the index file. */

Loading…
Cancel
Save