in git-common/src/main/java/jetbrains/buildServer/buildTriggers/vcs/git/command/GitCommandLine.java [65:144]
public ExecResult run(@NotNull GitCommandSettings settings) throws VcsException {
if (myCtx.isProvideCredHelper() && !getParametersList().getParametersString().contains("credential.helper")) {
//Disable credential helper if it wasn't specified by us, as default
//helper can require a user input. Do that even if our repository doesn't
//require any auth, auth can be required by submodules or git lfs.
//
//It would be cleaner to add the following
//
//[credential]
// helper =
//
//to the local repository config and not disable helpers in every command.
//But some commands ignore this setting, e.g. 'git submodules update':
//https://public-inbox.org/git/CAC+L6n0YeX_n_AysCLtBWkA+jPHwg7HmOWq2PLj75byxOZE=qQ@mail.gmail.com/
//if credential.helper is configured to the empty string, this resets the helper list to empty
getParametersList().addAt(0, "-c");
getParametersList().addAt(1, "credential.helper=");
String credHelperPath = CredentialsHelperConfig.configureCredentialHelperScript(myScriptGen);
if (!StringUtil.isEmptyOrSpaces(credHelperPath)) {
getParametersList().addAt(2, "-c");
getParametersList().addAt(3, "credential.helper=" + credHelperPath);
if (myCtx.isCleanCredHelperScript()) {
addPostAction(new Runnable() {
@Override
public void run() {
FileUtil.delete(new File(credHelperPath));
}
});
}
}
}
settings.getTraceEnv().entrySet().forEach(e -> addEnvParam(e.getKey(), e.getValue()));
setProxySettings();
final AuthSettings authSettings = settings.getAuthSettings();
if (authSettings == null) {
return doRunCommand(settings);
}
if (authSettings.getAuthMethod().isPasswordBased()) {
withAskPassScript(authSettings.getPassword(), askPassPath -> {
getParametersList().addAt(0, "-c");
getParametersList().addAt(1, "core.askpass=" + askPassPath);
addEnvParam("GIT_ASKPASS", askPassPath);
if (myCtx.isUseSshAskPass()) {
addEnvParam("SSH_ASKPASS", askPassPath);
addEnvParam("DISPLAY", ":0.0");
}
});
}
if (settings.isUseNativeSsh() && myCtx.isUseGitSshCommand()) {
configureGitSshCommand(settings);
}
GitCommandCredentials extraCredentials = authSettings.getExtraHTTPCredentials();
CredentialsHelperConfig config = new CredentialsHelperConfig();
for (ExtraHTTPCredentials creds : extraCredentials.getCredentials()) {
config.addCredentials(creds);
}
if (extraCredentials.isStoresOnlyDefaultCredential()) {
config.setMatchAllUrls(true);
} else if (extraCredentials.getCredentials().size() > 1){
getParametersList().addAt(0, "-c");
getParametersList().addAt(1, "credential.useHttpPath=true");
}
for (Map.Entry<String, String> e : config.getEnv().entrySet()) {
addEnvParam(e.getKey(), e.getValue());
}
return doRunCommand(settings);
}