Example usage for org.eclipse.jgit.api StashCreateCommand setIncludeUntracked

List of usage examples for org.eclipse.jgit.api StashCreateCommand setIncludeUntracked

Introduction

In this page you can find the example usage for org.eclipse.jgit.api StashCreateCommand setIncludeUntracked.

Prototype

public StashCreateCommand setIncludeUntracked(boolean includeUntracked) 

Source Link

Document

Whether to include untracked files in the stash.

Usage

From source file:org.eclipse.orion.server.git.servlets.GitStashHandlerV1.java

License:Open Source License

@Override
protected boolean handlePost(RequestInfo requestInfo) throws ServletException {

    JSONObject requestPayload = requestInfo.getJSONRequest();
    HttpServletRequest request = requestInfo.request;
    HttpServletResponse response = requestInfo.response;
    Repository db = requestInfo.db;/*from w  w  w. j a va  2  s. co m*/

    String indexMessage = requestPayload.optString(GitConstants.KEY_STASH_INDEX_MESSAGE);
    String workingDirectoryMessage = requestPayload.optString(GitConstants.KEY_STASH_WORKING_DIRECTORY_MESSAGE);
    boolean includeUntracked = requestPayload.optBoolean(GitConstants.KEY_STASH_INCLUDE_UNTRACKED, false);

    try {

        Git git = new Git(db);
        StashCreateCommand stashCreate = git.stashCreate();
        stashCreate.setPerson(new PersonIdent(db));
        stashCreate.setIncludeUntracked(includeUntracked);

        if (!indexMessage.isEmpty())
            stashCreate.setIndexMessage(indexMessage);

        if (!workingDirectoryMessage.isEmpty())
            stashCreate.setWorkingDirectoryMessage(workingDirectoryMessage);

        stashCreate.call();
        return true;

    } catch (Exception ex) {
        String msg = "An error occured for stash command.";
        return statusHandler.handleRequest(request, response,
                new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, msg, ex));
    }
}