/** * Finish, write, commit this change, and release the index lock. * <p> * If this method fails (returns false) the lock is still released. * <p> * This is a utility method for applications as the finish-write-commit * pattern is very common after using a builder to update entries. * * @return true if the commit was successful and the file contains the new * data; false if the commit failed and the file remains with the * old data. * @throws java.lang.IllegalStateException * the lock is not held. * @throws java.io.IOException * the output file could not be created. The caller no longer * holds the lock. */ public boolean commit() throws IOException { finish(); cache.write(); return cache.commit(); } }
@Override public String call() throws GitAPIException { try { DirCache index = repo.lockDirCache(); DirCacheEntry entry = index.getEntry(fileName); if (entry != null) { entry.setAssumeValid(assumeUnchanged); index.write(); index.commit(); return entry.getPathString(); } } catch (IOException e) { throw new JGitInternalException(e.getMessage(), e); } return null; } }
@Override public String call() throws GitAPIException { try { DirCache index = repo.lockDirCache(); DirCacheEntry entry = index.getEntry(fileName); if (entry != null) { entry.setAssumeValid(assumeUnchanged); index.write(); index.commit(); return entry.getPathString(); } } catch (IOException e) { throw new JGitInternalException(e.getMessage(), e); } return null; } }
/** * Finish, write, commit this change, and release the index lock. * <p> * If this method fails (returns false) the lock is still released. * <p> * This is a utility method for applications as the finish-write-commit * pattern is very common after using a builder to update entries. * * @return true if the commit was successful and the file contains the new * data; false if the commit failed and the file remains with the * old data. * @throws IllegalStateException * the lock is not held. * @throws IOException * the output file could not be created. The caller no longer * holds the lock. */ public boolean commit() throws IOException { finish(); cache.write(); return cache.commit(); } }
/** * Finish, write, commit this change, and release the index lock. * <p> * If this method fails (returns false) the lock is still released. * <p> * This is a utility method for applications as the finish-write-commit * pattern is very common after using a builder to update entries. * * @return true if the commit was successful and the file contains the new * data; false if the commit failed and the file remains with the * old data. * @throws java.lang.IllegalStateException * the lock is not held. * @throws java.io.IOException * the output file could not be created. The caller no longer * holds the lock. */ public boolean commit() throws IOException { finish(); cache.write(); return cache.commit(); } }
@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); } }