if (entries.size() == 1) {
deleteRef(stashRef);
return null;
}
ReflogWriter writer = new ReflogWriter(repo, true);
String stashLockRef = ReflogWriter.refLockFor(R_STASH);
File stashLockFile = writer.logFor(stashLockRef);
File stashFile = writer.logFor(R_STASH);
if (stashLockFile.exists())
throw new JGitInternalException(JGitText.get().stashDropFailed,
new LockFailedException(stashFile));
entries.remove(stashRefEntry);
ObjectId entryId = ObjectId.zeroId();
try {
for (int i = entries.size() - 1; i >= 0; i--) {
ReflogEntry entry = entries.get(i);
writer.log(stashLockRef, entryId, entry.getNewId(),
entry.getWho(), entry.getComment());
entryId = entry.getNewId();
}
if (!stashLockFile.renameTo(stashFile)) {
FileUtils.delete(stashFile);