GitCommandResult (@NotNull Computable<? extends GitLineHandler> handlerConstructor, @NotNull Computable<? extends OutputCollector> outputCollectorConstructor) { @NotNull GitCommandResult result; int authAttempt = 0; do { GitLineHandler handler = handlerConstructor.compute(); OutputCollector outputCollector = outputCollectorConstructor.compute(); boolean isCredHelperUsed = GitVcsApplicationSettings.getInstance().isUseCredentialHelper(); result = run(handler, outputCollector); if (isCredHelperUsed != GitVcsApplicationSettings.getInstance().isUseCredentialHelper()) { // do not spend attempt if the credential helper has been enabled continue; } authAttempt++; } while (result.isAuthenticationFailed() && authAttempt < 2); return result; }