Пример #1
0
 /**
  * Create a new in-core index representation, lock it, and read from disk.
  *
  * <p>The new index will be locked and then read before it is returned to the caller. Read
  * failures are reported as exceptions and therefore prevent the method from returning a partially
  * populated index. On read failure, the lock is released.
  *
  * @param repository repository containing the index to lock and read
  * @param indexChangedListener listener to be informed when DirCache is committed
  * @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 IOException the index file is present but could not be read, or the lock could not be
  *     obtained.
  * @throws CorruptObjectException the index file is using a format or extension that this library
  *     does not support.
  * @since 2.0
  */
 public static DirCache lock(
     final Repository repository, final IndexChangedListener indexChangedListener)
     throws CorruptObjectException, IOException {
   DirCache c = lock(repository.getIndexFile(), repository.getFS(), indexChangedListener);
   c.repository = repository;
   return c;
 }
Пример #2
0
 /**
  * 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 failures are reported
  * as exceptions and therefore prevent the method from returning a partially populated index.
  *
  * @param repository repository containing the index to read
  * @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 IOException the index file is present but could not be read.
  * @throws CorruptObjectException the index file is using a format or extension that this library
  *     does not support.
  */
 public static DirCache read(final Repository repository)
     throws CorruptObjectException, IOException {
   final DirCache c = read(repository.getIndexFile(), repository.getFS());
   c.repository = repository;
   return c;
 }