[git] Change GitHandler#setNoSSH() to setRemoteProtocol()

* Set remote protocol to null by default => safely remove all 82 calls
  to setNoSSH.
* For remote operations (pull, push, fetch and clone) set the protocol
  to SSH (HTTP is handled separately for now).

This is a preparation for working with HTTP via native Git.
This commit is contained in:
Kirill Likhodedov
2013-03-09 20:49:00 +04:00
parent eb3814b0e6
commit b2b8f2f957
38 changed files with 44 additions and 117 deletions
@@ -19,7 +19,6 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.containers.ContainerUtil;
@@ -160,7 +159,6 @@ public final class GitDeprecatedRemote {
*/
public static List<GitDeprecatedRemote> list(Project project, VirtualFile root) throws VcsException {
GitSimpleHandler handler = new GitSimpleHandler(project, root, GitCommand.REMOTE);
handler.setNoSSH(true);
handler.setSilent(true);
handler.addParameters("-v");
String output = handler.run();
@@ -209,7 +209,6 @@ public class GitRevisionNumber implements ShortVcsRevisionNumber {
*/
public static GitRevisionNumber resolve(Project project, VirtualFile vcsRoot, @NonNls String rev) throws VcsException {
GitSimpleHandler h = new GitSimpleHandler(project, vcsRoot, GitCommand.REV_LIST);
h.setNoSSH(true);
h.setSilent(true);
h.addParameters("--timestamp", "--max-count=1", rev);
h.endOptions();
@@ -65,7 +65,6 @@ public class GitTag extends GitReference {
public static void listAsStrings(final Project project, final VirtualFile root, final Collection<String> tags,
@Nullable final String containingCommit) throws VcsException {
GitSimpleHandler handler = new GitSimpleHandler(project, root, GitCommand.TAG);
handler.setNoSSH(true);
handler.setSilent(true);
handler.addParameters("-l");
if (containingCommit != null) {
@@ -522,7 +522,6 @@ public class GitUtil {
final Consumer<GitCommittedChangeList> consumer, boolean skipDiffsForMerge) throws VcsException {
GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.LOG);
h.setSilent(true);
h.setNoSSH(true);
h.addParameters("--pretty=format:%x04%x01" + GitChangeUtils.COMMITTED_CHANGELIST_FORMAT, "--name-status");
parametersSpecifier.consume(h);
@@ -937,7 +936,6 @@ public class GitUtil {
if (staged) {
diff.addParameters("--cached");
}
diff.setNoSSH(true);
diff.setStdoutSuppressed(true);
diff.setStderrSuppressed(true);
diff.setSilent(true);
@@ -146,7 +146,6 @@ public class GitAnnotationProvider implements AnnotationProvider, VcsCacheableAn
final List<VcsFileRevision> revisions,
final VirtualFile file) throws VcsException {
GitSimpleHandler h = new GitSimpleHandler(myProject, GitUtil.getGitRoot(repositoryFilePath), GitCommand.BLAME);
h.setNoSSH(true);
h.setStdoutSuppressed(true);
h.setCharset(file.getCharset());
h.addParameters("-p", "-l", "-t", "-w");
@@ -125,7 +125,6 @@ public class GitBranchUtil {
private static GitLocalBranch getCurrentBranchFromGit(@NotNull Project project, @NotNull VirtualFile root) {
GitSimpleHandler handler = new GitSimpleHandler(project, root, GitCommand.REV_PARSE);
handler.addParameters("--abbrev-ref", "HEAD");
handler.setNoSSH(true);
handler.setSilent(true);
try {
String name = handler.run();
@@ -189,14 +189,12 @@ public class GitChangeUtils {
GitSimpleHandler handler = new GitSimpleHandler(project, vcsRoot, GitCommand.REV_LIST);
handler.addParameters("--timestamp", "--max-count=1", reference);
handler.endOptions();
handler.setNoSSH(true);
handler.setSilent(true);
String output = handler.run();
StringTokenizer stk = new StringTokenizer(output, "\n\r \t", false);
if (!stk.hasMoreTokens()) {
GitSimpleHandler dh = new GitSimpleHandler(project, vcsRoot, GitCommand.LOG);
dh.addParameters("-1", "HEAD");
dh.setNoSSH(true);
dh.setSilent(true);
String out = dh.run();
LOG.info("Diagnostic output from 'git log -1 HEAD': [" + out + "]");
@@ -241,7 +239,6 @@ public class GitChangeUtils {
boolean skipDiffsForMerge,
boolean local, boolean revertable) throws VcsException {
GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.SHOW);
h.setNoSSH(true);
h.setSilent(true);
h.addParameters("--name-status", "--no-abbrev", "-M", "--pretty=format:" + COMMITTED_CHANGELIST_FORMAT, "--encoding=UTF-8",
revisionName, "--");
@@ -253,7 +250,6 @@ public class GitChangeUtils {
@Nullable
public static String getCommitAbbreviation(final Project project, final VirtualFile root, final SHAHash hash) {
GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.LOG);
h.setNoSSH(true);
h.setSilent(true);
h.addParameters("--max-count=1", "--pretty=%h", "--encoding=UTF-8", "\"" + hash.getValue() + "\"", "--");
try {
@@ -270,7 +266,6 @@ public class GitChangeUtils {
public static SHAHash commitExists(final Project project, final VirtualFile root, final String anyReference,
List<VirtualFile> paths, final String... parameters) {
GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.LOG);
h.setNoSSH(true);
h.setSilent(true);
h.addParameters(parameters);
h.addParameters("--max-count=1", "--pretty=%H", "--encoding=UTF-8", anyReference, "--");
@@ -290,7 +285,6 @@ public class GitChangeUtils {
public static boolean isAnyLevelChild(final Project project, final VirtualFile root, final SHAHash parent,
final String anyReferenceChild) {
GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.MERGE_BASE);
h.setNoSSH(true);
h.setSilent(true);
h.addParameters("\"" + parent.getValue() + "\"","\"" + anyReferenceChild + "\"", "--");
try {
@@ -306,7 +300,6 @@ public class GitChangeUtils {
@Nullable
public static List<AbstractHash> commitExistsByComment(final Project project, final VirtualFile root, final String anyReference) {
GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.LOG);
h.setNoSSH(true);
h.setSilent(true);
String escaped = StringUtil.escapeQuotes(anyReference);
escaped = StringUtil.escapeSlashes(escaped);
@@ -389,7 +382,6 @@ public class GitChangeUtils {
for (String parent : parents) {
final GitRevisionNumber parentRevision = resolveReference(project, root, parent);
GitSimpleHandler diffHandler = new GitSimpleHandler(project, root, GitCommand.DIFF);
diffHandler.setNoSSH(true);
diffHandler.setSilent(true);
diffHandler.addParameters("--name-status", "-M", parentRevision.getRev(), thisRevision.getRev());
String diff = diffHandler.run();
@@ -463,7 +455,6 @@ public class GitChangeUtils {
@NotNull String diffRange, @Nullable Collection<FilePath> dirtyPaths) {
GitSimpleHandler handler = new GitSimpleHandler(project, root, GitCommand.DIFF);
handler.addParameters("--name-status", "--diff-filter=ADCMRUXT", "-M", diffRange);
handler.setNoSSH(true);
handler.setSilent(true);
handler.setStdoutSuppressed(true);
handler.endOptions();
@@ -248,7 +248,6 @@ public class GitCheckinEnvironment implements CheckinEnvironment {
HashSet<FilePath> realRemoved = new HashSet<FilePath>();
// perform diff
GitSimpleHandler diff = new GitSimpleHandler(project, root, GitCommand.DIFF);
diff.setNoSSH(true);
diff.setSilent(true);
diff.setStdoutSuppressed(true);
diff.addParameters("--diff-filter=ADMRUX", "--name-status", "HEAD");
@@ -323,7 +322,6 @@ public class GitCheckinEnvironment implements CheckinEnvironment {
// perform merge commit
try {
GitSimpleHandler handler = new GitSimpleHandler(project, root, GitCommand.COMMIT);
handler.setNoSSH(true);
handler.addParameters("-F", messageFile.getAbsolutePath());
if (author != null) {
handler.addParameters("--author=" + author);
@@ -469,7 +467,6 @@ public class GitCheckinEnvironment implements CheckinEnvironment {
boolean amend = nextCommitAmend;
for (List<String> paths : VcsFileUtil.chunkPaths(root, files)) {
GitSimpleHandler handler = new GitSimpleHandler(project, root, GitCommand.COMMIT);
handler.setNoSSH(true);
if (amend) {
handler.addParameters("--amend");
}
@@ -26,10 +26,7 @@ import com.intellij.ui.DocumentAdapter;
import com.intellij.ui.EditorComboBox;
import com.intellij.util.ArrayUtil;
import git4idea.GitUtil;
import git4idea.commands.GitCommand;
import git4idea.commands.GitLineHandlerPasswordRequestAware;
import git4idea.commands.GitTask;
import git4idea.commands.GitTaskResult;
import git4idea.commands.*;
import git4idea.i18n.GitBundle;
import git4idea.remote.GitRememberedInputs;
import org.jetbrains.annotations.NonNls;
@@ -167,6 +164,7 @@ public class GitCloneDialog extends DialogWrapper {
*/
private boolean test(String url) {
final GitLineHandlerPasswordRequestAware handler = new GitLineHandlerPasswordRequestAware(myProject, new File("."), GitCommand.LS_REMOTE);
handler.setRemoteProtocol(GitRemoteProtocol.SSH);
handler.addParameters(url, "master");
GitTask task = new GitTask(myProject, handler, GitBundle.message("clone.testing", url));
GitTaskResult result = task.executeModal();
@@ -82,9 +82,6 @@ public abstract class GitHandler {
@NonNls
private Charset myCharset = Charset.forName("UTF-8"); // Character set to use for IO
@SuppressWarnings({"FieldAccessedSynchronizedAndUnsynchronized"})
private boolean myNoSSHFlag = false;
private final EventDispatcher<ProcessEventListener> myListeners = EventDispatcher.create(ProcessEventListener.class);
@SuppressWarnings({"FieldAccessedSynchronizedAndUnsynchronized"})
protected boolean mySilent; // if true, the command execution is not logged in version control view
@@ -100,6 +97,7 @@ public abstract class GitHandler {
private long myStartTime; // git execution start timestamp
private static final long LONG_TIME = 10 * 1000;
@Nullable private ModalityState myState;
@Nullable private GitRemoteProtocol myRemoteProtocol;
/**
@@ -219,23 +217,12 @@ public abstract class GitHandler {
return file;
}
/**
* Set SSH flag. This flag should be set to true for commands that never interact with remote repositories.
*
* @param value if value is true, the custom ssh is not used for the command.
*/
@SuppressWarnings({"WeakerAccess", "SameParameterValue"})
public void setNoSSH(boolean value) {
checkNotStarted();
myNoSSHFlag = value;
public void setRemoteProtocol(@NotNull GitRemoteProtocol remoteProtocol) {
myRemoteProtocol = remoteProtocol;
}
/**
* @return true if SSH is not invoked by this command.
*/
@SuppressWarnings({"WeakerAccess"})
public boolean isNoSSH() {
return myNoSSHFlag;
protected boolean isRemote() {
return myRemoteProtocol != null;
}
/**
@@ -430,7 +417,7 @@ public abstract class GitHandler {
}
// setup environment
if (!myNoSSHFlag && myProjectSettings.isIdeaSsh()) {
if (myRemoteProtocol == GitRemoteProtocol.SSH && myProjectSettings.isIdeaSsh()) {
GitSSHService ssh = GitSSHIdeaService.getInstance();
myEnv.put(GitSSHHandler.GIT_SSH_ENV, ssh.getScriptPath().getPath());
myHandlerNo = ssh.registerHandler(new GitSSHGUIHandler(myProject, myState));
@@ -502,7 +489,7 @@ public abstract class GitHandler {
* Cleanup environment
*/
protected synchronized void cleanupEnv() {
if (!myNoSSHFlag && !myEnvironmentCleanedUp) {
if (myRemoteProtocol == GitRemoteProtocol.SSH && !myEnvironmentCleanedUp) {
GitSSHService ssh = GitSSHIdeaService.getInstance();
myEnvironmentCleanedUp = true;
ssh.unregisterHandler(myHandlerNo);
@@ -101,7 +101,6 @@ public class GitImpl implements Git {
throws VcsException {
final Set<VirtualFile> untrackedFiles = new HashSet<VirtualFile>();
GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.LS_FILES);
h.setNoSSH(true);
h.setSilent(true);
h.addParameters("--exclude-standard", "--others", "-z");
h.endOptions();
@@ -133,11 +132,12 @@ public class GitImpl implements Git {
public GitCommandResult clone(@NotNull Project project, @NotNull File parentDirectory, @NotNull String url,
@NotNull String clonedDirectoryName, @NotNull GitLineHandlerListener... listeners) {
GitLineHandlerPasswordRequestAware handler = new GitLineHandlerPasswordRequestAware(project, parentDirectory, GitCommand.CLONE);
handler.setRemoteProtocol(GitRemoteProtocol.SSH);
handler.addParameters("--progress");
handler.addParameters(url);
handler.addParameters(clonedDirectoryName);
addListeners(handler, listeners);
return run(handler, true);
return run(handler);
}
@NotNull
@@ -154,7 +154,6 @@ public class GitImpl implements Git {
final GitLineHandler diff = new GitLineHandler(repository.getProject(), repository.getRoot(), GitCommand.DIFF);
diff.addParameters(parameters);
diff.addParameters(range);
diff.setNoSSH(true);
diff.setStdoutSuppressed(true);
diff.setStderrSuppressed(true);
diff.setSilent(true);
@@ -361,12 +360,13 @@ public class GitImpl implements Git {
@NotNull GitLineHandlerListener... listeners) {
final GitLineHandlerPasswordRequestAware h = new GitLineHandlerPasswordRequestAware(repository.getProject(), repository.getRoot(),
GitCommand.PUSH);
h.setRemoteProtocol(GitRemoteProtocol.SSH);
h.setSilent(false);
addListeners(h, listeners);
h.addProgressParameter();
h.addParameters(remote);
h.addParameters(spec);
return run(h, true);
return run(h);
}
@Override
@@ -417,16 +417,10 @@ public class GitImpl implements Git {
}
}
private static GitCommandResult run(@NotNull GitLineHandler handler) {
return run(handler, false);
}
/**
* Runs the given {@link GitLineHandler} in the current thread and returns the {@link GitCommandResult}.
*/
private static GitCommandResult run(@NotNull GitLineHandler handler, boolean remote) {
handler.setNoSSH(!remote);
private static GitCommandResult run(@NotNull GitLineHandler handler) {
final List<String> errorOutput = new ArrayList<String>();
final List<String> output = new ArrayList<String>();
final AtomicInteger exitCode = new AtomicInteger();
@@ -0,0 +1,25 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package git4idea.commands;
/**
* @author Kirill Likhodedov
*/
public enum GitRemoteProtocol {
GIT,
SSH,
HTTP
}
@@ -192,8 +192,8 @@ public class GitSimpleHandler extends GitTextHandler {
* @throws VcsException exception if process failed to start.
*/
public String run() throws VcsException {
if (!isNoSSH()) {
throw new IllegalStateException("Commands that require SSH could not be run using this method");
if (isRemote()) {
throw new IllegalStateException("Commands that require remote access could not be run using this method");
}
final VcsException[] ex = new VcsException[1];
final String[] result = new String[1];
@@ -54,7 +54,6 @@ public class GitConfigUtil {
*/
public static void getValues(Project project, VirtualFile root, String keyMask, Map<String, String> result) throws VcsException {
GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.CONFIG);
h.setNoSSH(true);
h.setSilent(true);
h.addParameters("--null");
if (keyMask != null) {
@@ -89,7 +88,6 @@ public class GitConfigUtil {
public static List<Pair<String, String>> getAllValues(Project project, VirtualFile root, @NonNls String key) throws VcsException {
List<Pair<String, String>> result = new ArrayList<Pair<String, String>>();
GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.CONFIG);
h.setNoSSH(true);
h.setSilent(true);
h.addParameters("--null", "--get-all", key);
String output = h.run();
@@ -116,7 +114,6 @@ public class GitConfigUtil {
@Nullable
public static String getValue(Project project, VirtualFile root, @NonNls String key) throws VcsException {
GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.CONFIG);
h.setNoSSH(true);
h.setSilent(true);
h.ignoreErrorCode(1);
h.addParameters("--null", "--get", key);
@@ -225,7 +222,6 @@ public class GitConfigUtil {
*/
public static void unsetValue(Project project, VirtualFile root, String key) throws VcsException {
GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.CONFIG);
h.setNoSSH(true);
h.setSilent(true);
h.ignoreErrorCode(1);
h.addParameters("--unset", key);
@@ -243,7 +239,6 @@ public class GitConfigUtil {
*/
public static void setValue(Project project, VirtualFile root, String key, String value, String... additionalParameters) throws VcsException {
GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.CONFIG);
h.setNoSSH(true);
h.setSilent(true);
h.ignoreErrorCode(1);
h.addParameters(additionalParameters);
@@ -55,7 +55,6 @@ public class GitTreeDiffProvider implements TreeDiffProvider {
for (List<String> pathList : VcsFileUtil.chunkPaths(vcsRoot, files)) {
GitSimpleHandler handler = new GitSimpleHandler(myProject, vcsRoot, GitCommand.DIFF);
handler.addParameters("--name-status", "--diff-filter=ADCRUX", "-M", "HEAD..." + searcher.getRemote().getFullName());
handler.setNoSSH(true);
handler.setSilent(true);
handler.setStdoutSuppressed(true);
handler.endOptions();
@@ -88,7 +88,6 @@ public class GitHistoryUtils {
public static long getHeadTs(final Project project, FilePath filePath) throws VcsException {
GitSimpleHandler h = new GitSimpleHandler(project, GitUtil.getGitRoot(filePath), GitCommand.LOG);
GitLogParser parser = new GitLogParser(project, SHORT_HASH, COMMIT_TIME);
h.setNoSSH(true);
h.setSilent(true);
h.addParameters("-n1", parser.getPretty());
h.addParameters("HEAD");
@@ -111,7 +110,6 @@ public class GitHistoryUtils {
filePath = getLastCommitName(project, filePath);
GitSimpleHandler h = new GitSimpleHandler(project, GitUtil.getGitRoot(filePath), GitCommand.LOG);
GitLogParser parser = shortHash ? new GitLogParser(project, SHORT_HASH, COMMIT_TIME) : new GitLogParser(project, HASH, COMMIT_TIME);
h.setNoSSH(true);
h.setSilent(true);
h.addParameters("-n1", parser.getPretty());
h.addParameters(!StringUtil.isEmpty(branch) ? branch : "--all");
@@ -134,7 +132,6 @@ public class GitHistoryUtils {
filePath = getLastCommitName(project, filePath);
GitSimpleHandler h = new GitSimpleHandler(project, GitUtil.getGitRoot(filePath), GitCommand.LOG);
GitLogParser parser = new GitLogParser(project, HASH, COMMIT_TIME, AUTHOR_NAME, COMMITTER_NAME, SUBJECT, BODY, RAW_BODY);
h.setNoSSH(true);
h.setSilent(true);
h.addParameters("-n1", parser.getPretty());
if (branch != null && !branch.isEmpty()) {
@@ -179,7 +176,6 @@ public class GitHistoryUtils {
filePath = getLastCommitName(project, filePath);
GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.LOG);
GitLogParser parser = new GitLogParser(project, GitLogParser.NameStatus.STATUS, HASH, COMMIT_TIME, SHORT_PARENTS);
h.setNoSSH(true);
h.setSilent(true);
h.addParameters("-n1", parser.getPretty(), "--name-status", t.getFullName());
h.endOptions();
@@ -202,7 +198,6 @@ public class GitHistoryUtils {
if (! GitUtil.isGitRoot(new File(root.getPath()))) throw new VcsException("Path " + root.getPath() + " is not git repository root");
final GitLineHandler h = new GitLineHandler(project, root, GitCommand.LOG);
h.setNoSSH(true);
h.setSilent(true);
h.addParameters("--branches", "--remotes", "--tags", "--pretty=format:%H%x20%ct%x0A", "--date-order", "--reverse", "--encoding=UTF-8", "--full-history",
"--sparse");
@@ -447,7 +442,6 @@ public class GitHistoryUtils {
private static GitLineHandler getLogHandler(Project project, VirtualFile root, GitLogParser parser, FilePath path, String lastCommit, String... parameters) {
final GitLineHandler h = new GitLineHandler(project, root, GitCommand.LOG);
h.setNoSSH(true);
h.setStdoutSuppressed(true);
h.addParameters("--name-status", parser.getPretty(), "--encoding=UTF-8", lastCommit);
if (parameters != null && parameters.length > 0) {
@@ -469,7 +463,6 @@ public class GitHistoryUtils {
// NB: we can't specify the filepath, because then rename detection will work only with the '--follow' option, which we don't wanna use.
final GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.SHOW);
final GitLogParser parser = new GitLogParser(project, GitLogParser.NameStatus.STATUS, HASH, COMMIT_TIME, SHORT_PARENTS);
h.setNoSSH(true);
h.setStdoutSuppressed(true);
h.addParameters("-M", "--name-status", parser.getPretty(), "--encoding=UTF-8", commit);
h.endOptions();
@@ -578,7 +571,6 @@ public class GitHistoryUtils {
path = getLastCommitName(project, path);
GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.LOG);
GitLogParser parser = new GitLogParser(project, HASH, COMMIT_TIME);
h.setNoSSH(true);
h.setStdoutSuppressed(true);
h.addParameters(parameters);
h.addParameters(parser.getPretty(), "--encoding=UTF-8");
@@ -626,7 +618,6 @@ public class GitHistoryUtils {
final GitLineHandler h = new GitLineHandler(project, root, GitCommand.LOG);
final GitLogParser parser = new GitLogParser(project, GitLogParser.NameStatus.STATUS, SHORT_HASH, HASH, COMMIT_TIME, AUTHOR_NAME, AUTHOR_TIME, AUTHOR_EMAIL,
COMMITTER_NAME, COMMITTER_EMAIL, SHORT_PARENTS, REF_NAMES, SUBJECT, BODY, RAW_BODY);
h.setNoSSH(true);
h.setStdoutSuppressed(true);
h.addParameters(parameters);
h.addParameters("--name-status", parser.getPretty(), "--encoding=UTF-8");
@@ -763,7 +754,6 @@ public class GitHistoryUtils {
GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.STASH.readLockingCommand());
GitLogParser parser = new GitLogParser(project, SHORT_HASH, SHORT_PARENTS);
h.setSilent(true);
h.setNoSSH(true);
h.addParameters("list");
h.addParameters("-n1");
h.addParameters(parser.getPretty());
@@ -778,7 +768,6 @@ public class GitHistoryUtils {
GitSimpleHandler h1 = new GitSimpleHandler(project, root, GitCommand.LOG);
GitLogParser parser1 = new GitLogParser(project, SHORT_HASH, SHORT_PARENTS, SUBJECT);
h1.setSilent(true);
h1.setNoSSH(true);
h1.addParameters("-n1");
h1.addParameters(parser1.getPretty());
//h1.endOptions();
@@ -813,7 +802,6 @@ public class GitHistoryUtils {
GitLogParser parser = new GitLogParser(project, GitLogParser.NameStatus.STATUS, SHORT_HASH, HASH, COMMIT_TIME, AUTHOR_NAME, AUTHOR_TIME, AUTHOR_EMAIL, COMMITTER_NAME,
COMMITTER_EMAIL, SHORT_PARENTS, REF_NAMES, SHORT_REF_LOG_SELECTOR, SUBJECT, BODY, RAW_BODY);
h.setSilent(true);
h.setNoSSH(true);
h.addParameters("list");
h.addParameters(parameters);
h.addParameters(parser.getPretty());
@@ -840,7 +828,6 @@ public class GitHistoryUtils {
GitLogParser parser = new GitLogParser(project, GitLogParser.NameStatus.STATUS,
SHORT_HASH, HASH, COMMIT_TIME, AUTHOR_NAME, AUTHOR_TIME, AUTHOR_EMAIL, COMMITTER_NAME,
COMMITTER_EMAIL, SHORT_PARENTS, REF_NAMES, SUBJECT, BODY, RAW_BODY);
h.setNoSSH(true);
h.setStdoutSuppressed(true);
h.addParameters("--name-status", "-M", parser.getPretty(), "--encoding=UTF-8");
h.addParameters(new ArrayList<String>(commitsIds));
@@ -860,7 +847,6 @@ public class GitHistoryUtils {
final VirtualFile root = GitUtil.getGitRoot(path);
GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.SHOW);
GitLogParser parser = new GitLogParser(project, GitLogParser.NameStatus.STATUS, AUTHOR_TIME);
h.setNoSSH(true);
h.setSilent(true);
h.addParameters("--name-status", parser.getPretty(), "--encoding=UTF-8");
h.addParameters(commitsId);
@@ -878,7 +864,6 @@ public class GitHistoryUtils {
final VirtualFile root = GitUtil.getGitRoot(path);
final GitLineHandler h = new GitLineHandler(project, root, GitCommand.LOG);
final GitLogParser parser = new GitLogParser(project, GitLogParser.NameStatus.NAME, SHORT_HASH, COMMIT_TIME, SHORT_PARENTS, AUTHOR_NAME);
h.setNoSSH(true);
h.setStdoutSuppressed(true);
h.addParameters(parameters);
h.addParameters(parser.getPretty(), "--encoding=UTF-8", "--full-history");
@@ -953,7 +938,6 @@ public class GitHistoryUtils {
@NotNull final String second)
throws VcsException {
GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.MERGE_BASE);
h.setNoSSH(true);
h.setSilent(true);
h.addParameters(first, second);
String output = h.run().trim();
@@ -205,7 +205,6 @@ public class LowLevelAccessImpl implements LowLevelAccess {
@Nullable String containingCommit) throws VcsException {
// preparing native command executor
final GitSimpleHandler handler = new GitSimpleHandler(project, root, GitCommand.BRANCH);
handler.setNoSSH(true);
handler.setSilent(true);
handler.addParameters("--no-color");
boolean remoteOnly = false;
@@ -156,7 +156,6 @@ public class GitMergeDialog extends DialogWrapper {
public void updateBranches() throws VcsException {
VirtualFile root = getSelectedRoot();
GitSimpleHandler handler = new GitSimpleHandler(myProject, root, GitCommand.BRANCH);
handler.setNoSSH(true);
handler.setSilent(true);
handler.addParameters("--no-color", "-a", "--no-merged");
String output = handler.run();
@@ -178,7 +177,6 @@ public class GitMergeDialog extends DialogWrapper {
GitLineHandler h = new GitLineHandler(myProject, root, GitCommand.MERGE);
// ignore merge failure
h.ignoreErrorCode(1);
h.setNoSSH(true);
if (myNoCommitCheckBox.isSelected()) {
h.addParameters("--no-commit");
}
@@ -288,7 +288,6 @@ public class GitMergeProvider implements MergeProvider2 {
VirtualFile root = e.getKey();
List<VirtualFile> files = e.getValue();
GitSimpleHandler h = new GitSimpleHandler(myProject, root, GitCommand.LS_FILES);
h.setNoSSH(true);
h.setStdoutSuppressed(true);
h.setSilent(true);
h.addParameters("--exclude-standard", "--unmerged", "-t", "-z");
@@ -65,7 +65,6 @@ public class GitMerger {
public void mergeCommit(VirtualFile root) throws VcsException {
GitSimpleHandler handler = new GitSimpleHandler(myProject, root, GitCommand.COMMIT);
handler.setNoSSH(true);
File gitDir = new File(VfsUtilCore.virtualToIoFile(root), GitUtil.DOT_GIT);
File messageFile = new File(gitDir, GitRepositoryFiles.MERGE_MSG);
@@ -27,6 +27,7 @@ import git4idea.GitRemoteBranch;
import git4idea.GitUtil;
import git4idea.commands.GitCommand;
import git4idea.commands.GitLineHandler;
import git4idea.commands.GitRemoteProtocol;
import git4idea.i18n.GitBundle;
import git4idea.repo.GitBranchTrackInfo;
import git4idea.repo.GitRemote;
@@ -158,6 +159,7 @@ public class GitPullDialog extends DialogWrapper {
// ignore merge failure for the pull
h.ignoreErrorCode(1);
if (pull) {
h.setRemoteProtocol(GitRemoteProtocol.SSH);
h.addProgressParameter();
}
h.addParameters("--no-stat");
@@ -84,7 +84,6 @@ public class MergeChangeCollector {
public @NotNull Set<String> getUnmergedPaths() throws VcsException {
String root = myRoot.getPath();
final GitSimpleHandler h = new GitSimpleHandler(myProject, myRoot, GitCommand.LS_FILES);
h.setNoSSH(true);
h.setSilent(true);
h.addParameters("--unmerged");
final String result = h.run();
@@ -158,7 +157,6 @@ public class MergeChangeCollector {
String root = myRoot.getPath();
GitSimpleHandler h = new GitSimpleHandler(myProject, myRoot, GitCommand.DIFF);
h.setSilent(true);
h.setNoSSH(true);
// note that moves are not detected here
h.addParameters("--name-status", "--diff-filter=ADMRUX", revisions);
for (StringScanner s = new StringScanner(h.run()); s.hasMoreData();) {
@@ -163,7 +163,6 @@ public class GitRebaseDialog extends DialogWrapper {
public GitLineHandler handler() {
GitLineHandler h = new GitLineHandler(myProject, gitRoot(), GitCommand.REBASE);
h.setNoSSH(true);
if (myInteractiveCheckBox.isSelected() && myInteractiveCheckBox.isEnabled()) {
h.addParameters("-i");
}
@@ -225,7 +225,6 @@ public class GitRebaser {
private void stageEverything(@NotNull VirtualFile root) throws VcsException {
GitSimpleHandler handler = new GitSimpleHandler(myProject, root, GitCommand.ADD);
handler.setSilent(false);
handler.setNoSSH(true);
handler.addParameters("--update");
handler.run();
}
@@ -179,7 +179,6 @@ public class GitRollbackEnvironment implements RollbackEnvironment {
public void revert(final VirtualFile root, final List<FilePath> files) throws VcsException {
for (List<String> paths : VcsFileUtil.chunkPaths(root, files)) {
GitSimpleHandler handler = new GitSimpleHandler(myProject, root, GitCommand.CHECKOUT);
handler.setNoSSH(true);
handler.addParameters("HEAD");
handler.endOptions();
handler.addParameters(paths);
@@ -247,7 +246,6 @@ public class GitRollbackEnvironment implements RollbackEnvironment {
public static void resetHardLocal(final Project project, final VirtualFile root) {
GitSimpleHandler handler = new GitSimpleHandler(project, root, GitCommand.RESET);
handler.setNoSSH(true);
handler.addParameters("--hard");
handler.endOptions();
GitHandlerUtil.runInCurrentThread(handler, null);
@@ -56,7 +56,6 @@ public class GitStashUtils {
final Consumer<StashInfo> consumer) {
GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.STASH.readLockingCommand());
h.setSilent(true);
h.setNoSSH(true);
h.addParameters("list");
String out;
try {
@@ -121,7 +121,6 @@ class GitNewChangesCollector extends GitChangesCollector {
GitSimpleHandler handler = new GitSimpleHandler(myProject, myVcsRoot, GitCommand.STATUS);
final String[] params = {"--porcelain", "-z", "--untracked-files=no"}; // untracked files are stored separately
handler.addParameters(params);
handler.setNoSSH(true);
handler.setSilent(true);
handler.setStdoutSuppressed(true);
handler.endOptions();
@@ -130,7 +129,6 @@ class GitNewChangesCollector extends GitChangesCollector {
// if there are too much files, just get all changes for the project
handler = new GitSimpleHandler(myProject, myVcsRoot, GitCommand.STATUS);
handler.addParameters(params);
handler.setNoSSH(true);
handler.setSilent(true);
handler.setStdoutSuppressed(true);
handler.endOptions();
@@ -134,7 +134,6 @@ class GitOldChangesCollector extends GitChangesCollector {
GitSimpleHandler handler = new GitSimpleHandler(myProject, myVcsRoot, GitCommand.UPDATE_INDEX);
handler.addParameters("--refresh", "--ignore-missing");
handler.setSilent(true);
handler.setNoSSH(true);
handler.setStdoutSuppressed(true);
handler.ignoreErrorCode(1);
handler.run();
@@ -161,7 +160,6 @@ class GitOldChangesCollector extends GitChangesCollector {
}
GitSimpleHandler handler = new GitSimpleHandler(myProject, myVcsRoot, GitCommand.LS_FILES);
handler.addParameters("--cached");
handler.setNoSSH(true);
handler.setSilent(true);
handler.setStdoutSuppressed(true);
// During init diff does not works because HEAD
@@ -193,7 +191,6 @@ class GitOldChangesCollector extends GitChangesCollector {
GitSimpleHandler handler = new GitSimpleHandler(myProject, myVcsRoot, GitCommand.LS_FILES);
handler.addParameters("-v", "--unmerged");
handler.setSilent(true);
handler.setNoSSH(true);
handler.setStdoutSuppressed(true);
// run handler and collect changes
parseFiles(handler.run());
@@ -201,7 +198,6 @@ class GitOldChangesCollector extends GitChangesCollector {
handler = new GitSimpleHandler(myProject, myVcsRoot, GitCommand.LS_FILES);
handler.addParameters("-v", "--others", "--exclude-standard");
handler.setSilent(true);
handler.setNoSSH(true);
handler.setStdoutSuppressed(true);
handler.endOptions();
handler.addRelativePaths(dirtyPaths);
@@ -209,7 +205,6 @@ class GitOldChangesCollector extends GitChangesCollector {
handler = new GitSimpleHandler(myProject, myVcsRoot, GitCommand.LS_FILES);
handler.addParameters("-v", "--others", "--exclude-standard");
handler.setSilent(true);
handler.setNoSSH(true);
handler.setStdoutSuppressed(true);
handler.endOptions();
}
@@ -118,7 +118,6 @@ public class GitResetDialog extends DialogWrapper {
*/
public GitLineHandler handler() {
GitLineHandler handler = new GitLineHandler(myProject, getGitRoot(), GitCommand.RESET);
handler.setNoSSH(true);
String type = (String)myResetTypeComboBox.getSelectedItem();
if (SOFT.equals(type)) {
handler.addParameters("--soft");
@@ -180,7 +180,6 @@ public class GitTagDialog extends DialogWrapper {
}
try {
GitSimpleHandler h = new GitSimpleHandler(myProject, getGitRoot(), GitCommand.TAG);
h.setNoSSH(true);
if (hasMessage) {
h.addParameters("-a");
}
@@ -250,7 +249,6 @@ public class GitTagDialog extends DialogWrapper {
private void fetchTags() {
myExistingTags.clear();
GitSimpleHandler h = new GitSimpleHandler(myProject, getGitRoot(), GitCommand.TAG);
h.setNoSSH(true);
h.setSilent(true);
String output = GitHandlerUtil.doSynchronously(h, GitBundle.getString("tag.getting.existing.tags"), h.printableCommandLine());
for (StringScanner s = new StringScanner(output); s.hasMoreData();) {
@@ -163,7 +163,6 @@ public class GitUnstashDialog extends DialogWrapper {
GitBundle.message("git.unstash.clear.confirmation.message"),
GitBundle.message("git.unstash.clear.confirmation.title"), Messages.getWarningIcon())) {
GitLineHandler h = new GitLineHandler(myProject, getGitRoot(), GitCommand.STASH);
h.setNoSSH(true);
h.addParameters("clear");
GitHandlerUtil.doSynchronously(h, GitBundle.getString("unstash.clearing.stashes"), h.printableCommandLine());
refreshStashList();
@@ -203,7 +202,6 @@ public class GitUnstashDialog extends DialogWrapper {
private GitSimpleHandler dropHandler(String stash) {
GitSimpleHandler h = new GitSimpleHandler(myProject, getGitRoot(), GitCommand.STASH);
h.setNoSSH(true);
h.addParameters("drop");
addStashParameter(h, stash);
return h;
@@ -216,7 +214,6 @@ public class GitUnstashDialog extends DialogWrapper {
String selectedStash = getSelectedStash().getStash();
try {
GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.REV_LIST);
h.setNoSSH(true);
h.setSilent(true);
h.addParameters("--timestamp", "--max-count=1");
addStashParameter(h, selectedStash);
@@ -343,7 +340,6 @@ public class GitUnstashDialog extends DialogWrapper {
*/
private GitLineHandler handler() {
GitLineHandler h = new GitLineHandler(myProject, getGitRoot(), GitCommand.STASH);
h.setNoSSH(true);
String branch = myBranchTextField.getText();
if (branch.length() == 0) {
h.addParameters(myPopStashCheckBox.isSelected() ? "pop" : "apply");
@@ -211,6 +211,7 @@ public class GitFetcher {
private GitFetchResult fetchNatively(@NotNull VirtualFile root, @NotNull GitRemote remote, @Nullable String branch) {
final GitLineHandlerPasswordRequestAware h = new GitLineHandlerPasswordRequestAware(myProject, root, GitCommand.FETCH);
h.setRemoteProtocol(GitRemoteProtocol.SSH);
h.addProgressParameter();
if (GitVersionSpecialty.SUPPORTS_FETCH_PRUNE.existsIn(myVcs.getVersion())) {
h.addParameters("--prune");
@@ -189,7 +189,6 @@ public class GitMergeUpdater extends GitUpdater {
private void cancel() {
try {
GitSimpleHandler h = new GitSimpleHandler(myProject, myRoot, GitCommand.RESET);
h.setNoSSH(true);
h.addParameters("--merge");
h.run();
} catch (VcsException e) {
@@ -135,7 +135,6 @@ public class GitUpdateLocallyModifiedDialog extends DialogWrapper {
String rootPath = root.getPath();
GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.DIFF);
h.addParameters("--name-status");
h.setNoSSH(true);
h.setSilent(true);
h.setStdoutSuppressed(true);
StringScanner s = new StringScanner(h.run());
@@ -172,7 +172,6 @@ public abstract class GitUpdater {
protected boolean hasRemoteChanges(@NotNull String currentBranch, @NotNull String remoteBranch) throws VcsException {
GitSimpleHandler handler = new GitSimpleHandler(myProject, myRoot, GitCommand.REV_LIST);
handler.setSilent(true);
handler.setNoSSH(true);
handler.addParameters("-1");
handler.addParameters(currentBranch + ".." + remoteBranch);
String output = handler.run();
@@ -61,7 +61,6 @@ public class GitFileUtils {
handler.addParameters(additionalOptions);
handler.endOptions();
handler.addParameters(paths);
handler.setNoSSH(true);
handler.run();
}
}
@@ -80,7 +79,6 @@ public class GitFileUtils {
GitSimpleHandler handler = new GitSimpleHandler(project, root, GitCommand.RM);
handler.endOptions();
handler.addParameters(paths);
handler.setNoSSH(true);
handler.run();
}
}
@@ -159,7 +157,6 @@ public class GitFileUtils {
handler.addParameters("--ignore-errors");
handler.endOptions();
handler.addParameters(paths);
handler.setNoSSH(true);
handler.run();
}
}
@@ -168,7 +165,6 @@ public class GitFileUtils {
private static List<String> excludeIgnoredFiles(@NotNull Project project, @NotNull VirtualFile root,
@NotNull List<String> paths) throws VcsException {
GitSimpleHandler handler = new GitSimpleHandler(project, root, GitCommand.LS_FILES);
handler.setNoSSH(true);
handler.setSilent(true);
handler.addParameters("--ignored", "--others", "--exclude-standard");
handler.endOptions();
@@ -197,7 +193,6 @@ public class GitFileUtils {
*/
public static byte[] getFileContent(Project project, VirtualFile root, String revisionOrBranch, String relativePath) throws VcsException {
GitBinaryHandler h = new GitBinaryHandler(project, root, GitCommand.SHOW);
h.setNoSSH(true);
h.setSilent(true);
h.addParameters(revisionOrBranch + ":" + relativePath);
return h.run();
@@ -180,7 +180,6 @@ public class GithubRebaseAction extends DumbAwareAction {
LOG.info("Adding GitHub parent as a remote host");
ProgressManager.getInstance().getProgressIndicator().setText("Adding GitHub parent as a remote host");
final GitSimpleHandler addRemoteHandler = new GitSimpleHandler(project, root, GitCommand.REMOTE);
addRemoteHandler.setNoSSH(true);
addRemoteHandler.setSilent(true);
remoteForForkParentRepo.set("upstream");
@@ -188,7 +188,6 @@ public class GithubShareAction extends DumbAwareAction {
if (!gitDetected) {
LOG.info("No git detected, creating empty git repo");
final GitLineHandler h = new GitLineHandler(project, root, GitCommand.INIT);
h.setNoSSH(true);
GitHandlerUtil.doSynchronously(h, GitBundle.getString("initializing.title"), h.printableCommandLine());
if (!h.errors().isEmpty()) {
GitUIUtil.showOperationErrors(project, h.errors(), "git init");
@@ -216,7 +215,6 @@ public class GithubShareAction extends DumbAwareAction {
//git remote add origin git@github.com:login/name.git
LOG.info("Adding GitHub as a remote host");
final GitSimpleHandler addRemoteHandler = new GitSimpleHandler(project, root, GitCommand.REMOTE);
addRemoteHandler.setNoSSH(true);
addRemoteHandler.setSilent(true);
final String remoteUrl = GithubApiUtil.getGitHost() + "/" + login + "/" + name + ".git";
addRemoteHandler.addParameters("add", "origin", remoteUrl);
@@ -372,7 +370,6 @@ public class GithubShareAction extends DumbAwareAction {
}
GitSimpleHandler handler = new GitSimpleHandler(project, root, GitCommand.COMMIT);
handler.addParameters("-m", "First commit");
handler.setNoSSH(true);
handler.endOptions();
handler.run();
}