git4idea: Implemeted forced merge/rebase and stash options for update operation
[fedora-idea.git] / plugins / git4idea / src / git4idea / update / GitStashUtils.java
blobe7e97540334426a343fbe931e7f9f94c9557c57b
1 package git4idea.update;
3 import com.intellij.openapi.project.Project;
4 import com.intellij.openapi.vcs.VcsException;
5 import com.intellij.openapi.vfs.VirtualFile;
6 import git4idea.commands.GitHandler;
7 import git4idea.commands.GitSimpleHandler;
8 import org.jetbrains.annotations.NotNull;
10 /**
11 * The class contains utilities for creating and removing stashes.
13 public class GitStashUtils {
14 private GitStashUtils() {
17 /**
18 * Create stash for later use
20 * @param project the project to use
21 * @param root the root
22 * @param message the message for the stash
23 * @return true if the stash was created, false otherwise
25 public static boolean saveStash(@NotNull Project project, @NotNull VirtualFile root, final String message) throws VcsException {
26 GitSimpleHandler handler = new GitSimpleHandler(project, root, GitHandler.STASH);
27 handler.setNoSSH(true);
28 handler.addParameters("save", message);
29 String output = handler.run();
30 return !output.startsWith("No local changes to save");
33 /**
34 * Create stash for later use
36 * @param project the project to use
37 * @param root the root
39 public static void popLastStash(@NotNull Project project, @NotNull VirtualFile root) throws VcsException {
40 GitSimpleHandler handler = new GitSimpleHandler(project, root, GitHandler.STASH);
41 handler.setNoSSH(true);
42 handler.addParameters("pop");
43 handler.run();