/** * Load a reference tree. * * @param reader * reader to scan the reference tree with. * @param tree * the tree to read. * @return the ref tree read from the commit. * @throws java.io.IOException * the repository cannot be accessed through the reader. * @throws org.eclipse.jgit.errors.CorruptObjectException * a tree object is corrupt and cannot be read. * @throws org.eclipse.jgit.errors.IncorrectObjectTypeException * a tree object wasn't actually a tree. * @throws org.eclipse.jgit.errors.MissingObjectException * a reference tree object doesn't exist. */ public static RefTree read(ObjectReader reader, RevTree tree) throws MissingObjectException, IncorrectObjectTypeException, CorruptObjectException, IOException { return new RefTree(DirCache.read(reader, tree)); }
/** * 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. * * @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 org.eclipse.jgit.errors.NoWorkTreeException * if this is bare, which implies it has no working directory. * See {@link #isBare()}. * @throws java.io.IOException * the index file is present but could not be read. * @throws org.eclipse.jgit.errors.CorruptObjectException * the index file is using a format or extension that this * library does not support. */ @NonNull public DirCache readDirCache() throws NoWorkTreeException, CorruptObjectException, IOException { return DirCache.read(this); }
/** * 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 indexLocation * location of the index file on disk. * @param fs * the file system abstraction which will be necessary to perform * certain file system operations. * @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 java.io.IOException * the index file is present but could not be read. * @throws org.eclipse.jgit.errors.CorruptObjectException * the index file is using a format or extension that this * library does not support. */ public static DirCache read(File indexLocation, FS fs) throws CorruptObjectException, IOException { final DirCache c = new DirCache(indexLocation, fs); c.read(); return c; }
private DirCache newDirCache() throws IOException { if (commit != null) { return DirCache.read(reader, commit.getTree()); } return DirCache.newInCore(); }
/** * 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 java.io.IOException * the index file is present but could not be read. * @throws org.eclipse.jgit.errors.CorruptObjectException * the index file is using a format or extension that this * library does not support. */ public static DirCache read(Repository repository) throws CorruptObjectException, IOException { final DirCache c = read(repository.getIndexFile(), repository.getFS()); c.repository = repository; return c; }
public static void main(String[] args) throws IOException { try (Repository repository = CookbookHelper.openJGitCookbookRepository()) { // DirCache contains all files of the repository DirCache index = DirCache.read(repository); System.out.println("DirCache has " + index.getEntryCount() + " items"); for (int i = 0; i < index.getEntryCount(); i++) { // the number after the AnyObjectId is the "stage", see the constants in DirCacheEntry System.out.println("Item " + i + ": " + index.getEntry(i)); } // System.out.println("Now printing staged items..."); for (int i = 0; i < index.getEntryCount(); i++) { DirCacheEntry entry = index.getEntry(i); if (entry.getStage() != DirCacheEntry.STAGE_0) { System.out.println("Item " + i + ": " + entry); } } } } }
public static void main(String[] args) throws IOException { try (Repository repository = CookbookHelper.openJGitCookbookRepository()) { // DirCache contains all files of the repository DirCache index = DirCache.read(repository); System.out.println("DirCache has " + index.getEntryCount() + " items"); for (int i = 0; i < index.getEntryCount(); i++) { // the number after the AnyObjectId is the "stage", see the constants in DirCacheEntry System.out.println("Item " + i + ": " + index.getEntry(i)); } // System.out.println("Now printing staged items..."); for (int i = 0; i < index.getEntryCount(); i++) { DirCacheEntry entry = index.getEntry(i); if (entry.getStage() != DirCacheEntry.STAGE_0) { System.out.println("Item " + i + ": " + entry); } } } } }
workingTreeIterator = null; try { dircache = DirCache.read(reader, currentBase.getTree()); inCore = true;
c.read(); } catch (IOException e) { c.unlock();
/** * Load a reference tree. * * @param reader * reader to scan the reference tree with. * @param tree * the tree to read. * @return the ref tree read from the commit. * @throws IOException * the repository cannot be accessed through the reader. * @throws CorruptObjectException * a tree object is corrupt and cannot be read. * @throws IncorrectObjectTypeException * a tree object wasn't actually a tree. * @throws MissingObjectException * a reference tree object doesn't exist. */ public static RefTree read(ObjectReader reader, RevTree tree) throws MissingObjectException, IncorrectObjectTypeException, CorruptObjectException, IOException { return new RefTree(DirCache.read(reader, tree)); }
/** * Load a reference tree. * * @param reader * reader to scan the reference tree with. * @param tree * the tree to read. * @return the ref tree read from the commit. * @throws java.io.IOException * the repository cannot be accessed through the reader. * @throws org.eclipse.jgit.errors.CorruptObjectException * a tree object is corrupt and cannot be read. * @throws org.eclipse.jgit.errors.IncorrectObjectTypeException * a tree object wasn't actually a tree. * @throws org.eclipse.jgit.errors.MissingObjectException * a reference tree object doesn't exist. */ public static RefTree read(ObjectReader reader, RevTree tree) throws MissingObjectException, IncorrectObjectTypeException, CorruptObjectException, IOException { return new RefTree(DirCache.read(reader, tree)); }
/** * 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. * * @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 NoWorkTreeException * if this is bare, which implies it has no working directory. * See {@link #isBare()}. * @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. */ @NonNull public DirCache readDirCache() throws NoWorkTreeException, CorruptObjectException, IOException { return DirCache.read(this); }
/** * 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. * * @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 org.eclipse.jgit.errors.NoWorkTreeException * if this is bare, which implies it has no working directory. * See {@link #isBare()}. * @throws java.io.IOException * the index file is present but could not be read. * @throws org.eclipse.jgit.errors.CorruptObjectException * the index file is using a format or extension that this * library does not support. */ @NonNull public DirCache readDirCache() throws NoWorkTreeException, CorruptObjectException, IOException { return DirCache.read(this); }
/** * 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 indexLocation * location of the index file on disk. * @param fs * the file system abstraction which will be necessary to perform * certain file system operations. * @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 File indexLocation, final FS fs) throws CorruptObjectException, IOException { final DirCache c = new DirCache(indexLocation, fs); c.read(); return c; }
/** * 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 indexLocation * location of the index file on disk. * @param fs * the file system abstraction which will be necessary to perform * certain file system operations. * @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 java.io.IOException * the index file is present but could not be read. * @throws org.eclipse.jgit.errors.CorruptObjectException * the index file is using a format or extension that this * library does not support. */ public static DirCache read(File indexLocation, FS fs) throws CorruptObjectException, IOException { final DirCache c = new DirCache(indexLocation, fs); c.read(); return c; }
private DirCache newDirCache() throws IOException { if (commit != null) { return DirCache.read(reader, commit.getTree()); } return DirCache.newInCore(); }
private DirCache newDirCache() throws IOException { if (commit != null) { return DirCache.read(reader, commit.getTree()); } return DirCache.newInCore(); }
/** * 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; }
/** * 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 java.io.IOException * the index file is present but could not be read. * @throws org.eclipse.jgit.errors.CorruptObjectException * the index file is using a format or extension that this * library does not support. */ public static DirCache read(Repository repository) throws CorruptObjectException, IOException { final DirCache c = read(repository.getIndexFile(), repository.getFS()); c.repository = repository; return c; }
@Override protected void run() throws Exception { final DirCache cache = db.readDirCache(); if (!cache.lock()) throw die(CLIText.get().failedToLockIndex); cache.read(); cache.write(); if (!cache.commit()) throw die(CLIText.get().failedToCommitIndex); } }