IDEA-87508 Disable GIT_TRACE before validating executable

This commit is contained in:
Dmitriy Smirnov
2017-08-02 14:36:29 +03:00
parent b20a9425fa
commit 113555f219
3 changed files with 13 additions and 4 deletions
@@ -35,6 +35,7 @@ import javax.swing.event.HyperlinkEvent;
import java.awt.*;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import static com.intellij.notification.NotificationDisplayType.STICKY_BALLOON;
@@ -98,15 +99,16 @@ public abstract class ExecutableValidator {
* @return true if process with the supplied executable completed without errors and with exit code 0.
*/
protected boolean isExecutableValid(@NotNull String executable) {
return doCheckExecutable(executable, Collections.emptyList());
return doCheckExecutable(executable, Collections.emptyList(), Collections.emptyMap());
}
protected static boolean doCheckExecutable(@NotNull String executable, @NotNull List<String> processParameters) {
protected static boolean doCheckExecutable(@NotNull String executable, @NotNull List<String> processParameters, @NotNull Map<String, String> envVariables) {
try {
GeneralCommandLine commandLine = new GeneralCommandLine();
commandLine.setExePath(executable);
commandLine.addParameters(processParameters);
commandLine.setCharset(CharsetToolkit.getDefaultSystemCharset());
commandLine.withEnvironment(envVariables);
CapturingProcessHandler handler = new CapturingProcessHandler(commandLine);
ProcessOutput result = handler.runProcess(TIMEOUT_MS);
boolean timeout = result.isTimeout();
@@ -471,7 +471,7 @@ public abstract class GitHandler {
}
private void unsetGitTrace() {
myEnv.put("GIT_TRACE", "0");
myEnv.putAll(getCommonEnvironment());
}
private void setupHttpAuthenticator() throws IOException {
@@ -808,4 +808,10 @@ public abstract class GitHandler {
public void setInputProcessor(@Nullable ThrowableConsumer<OutputStream, IOException> inputProcessor) {
myInputProcessor = inputProcessor;
}
public static @NotNull Map<String, String> getCommonEnvironment() {
Map<String,String> commonEnv = new HashMap<>();
commonEnv.put("GIT_TRACE","0");
return commonEnv;
}
}
@@ -18,6 +18,7 @@ package git4idea.config;
import com.intellij.execution.ExecutableValidator;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vcs.VcsException;
import git4idea.commands.GitHandler;
import git4idea.i18n.GitBundle;
import org.jetbrains.annotations.NotNull;
@@ -47,7 +48,7 @@ public class GitExecutableValidator extends ExecutableValidator {
@Override
public boolean isExecutableValid(@NotNull String executable) {
return doCheckExecutable(executable, Collections.singletonList("--version"));
return doCheckExecutable(executable, Collections.singletonList("--version"), GitHandler.getCommonEnvironment());
}
/**