if (isStashEmpty(git)) {
String msg = "Failed to apply stashed changes due to an empty stash.";
return statusHandler.handleRequest(request, response, new ServerStatus(IStatus.WARNING, HttpServletResponse.SC_BAD_REQUEST, msg, null));
}
StashApplyCommand applyCommand = new StashApplyCommand(db);
if (stashRev != null) {
StashRef stashRef = getStashRef(git, stashRev);
if (stashRef == null) {
String msg = NLS.bind("Invalid stash reference {0}.", stashRev);
return statusHandler.handleRequest(request, response, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_BAD_REQUEST, msg, null));
}
applyCommand.setStashRef(stashRef.getStringRef());
applyCommand.setApplyUntracked(applyUntracked);
applyCommand.setApplyIndex(applyIndex);
applyCommand.call();
} else {
/* git stash pop */
applyCommand.setApplyUntracked(applyUntracked);
applyCommand.setApplyIndex(applyIndex);
applyCommand.call();
StashDropCommand dropCommand = git.stashDrop();
dropCommand.setAll(false);
dropCommand.call();