diff --git a/plugins/git4idea/src/git4idea/commands/Git.java b/plugins/git4idea/src/git4idea/commands/Git.java index 67872af67419..e56210809f1d 100644 --- a/plugins/git4idea/src/git4idea/commands/Git.java +++ b/plugins/git4idea/src/git4idea/commands/Git.java @@ -92,6 +92,10 @@ public interface Git { @NotNull GitCommandResult tip(@NotNull GitRepository repository, @NotNull String branchName); + @NotNull + GitCommandResult push(@NotNull GitRepository repository, @NotNull String remote, @NotNull String url, @NotNull String spec, + boolean updateTracking, @NotNull GitLineHandlerListener... listeners); + @NotNull GitCommandResult push(@NotNull GitRepository repository, @NotNull String remote, @NotNull String url, @NotNull String spec, @NotNull GitLineHandlerListener... listeners); diff --git a/plugins/git4idea/src/git4idea/commands/GitImpl.java b/plugins/git4idea/src/git4idea/commands/GitImpl.java index 750ee759fe72..189b4d47122e 100644 --- a/plugins/git4idea/src/git4idea/commands/GitImpl.java +++ b/plugins/git4idea/src/git4idea/commands/GitImpl.java @@ -357,7 +357,7 @@ public class GitImpl implements Git { @Override @NotNull public GitCommandResult push(@NotNull GitRepository repository, @NotNull String remote, @NotNull String url, @NotNull String spec, - @NotNull GitLineHandlerListener... listeners) { + boolean updateTracking, @NotNull GitLineHandlerListener... listeners) { final GitLineHandlerPasswordRequestAware h = new GitLineHandlerPasswordRequestAware(repository.getProject(), repository.getRoot(), GitCommand.PUSH); h.setUrl(url); @@ -366,9 +366,19 @@ public class GitImpl implements Git { h.addProgressParameter(); h.addParameters(remote); h.addParameters(spec); + if (updateTracking) { + h.addParameters("--set-upstream"); + } return run(h); } + @Override + @NotNull + public GitCommandResult push(@NotNull GitRepository repository, @NotNull String remote, @NotNull String url, @NotNull String spec, + @NotNull GitLineHandlerListener... listeners) { + return push(repository, remote, url, spec, false, listeners); + } + @Override @NotNull public GitCommandResult push(@NotNull GitRepository repository, @NotNull GitPushSpec pushSpec, @NotNull String url, diff --git a/plugins/git4idea/testFramework/git4idea/test/GitTestImpl.java b/plugins/git4idea/testFramework/git4idea/test/GitTestImpl.java index 0f0b1475a489..3e1aa8bb61c0 100644 --- a/plugins/git4idea/testFramework/git4idea/test/GitTestImpl.java +++ b/plugins/git4idea/testFramework/git4idea/test/GitTestImpl.java @@ -188,6 +188,13 @@ public class GitTestImpl implements Git { return execute(repository, "rev-list -1 " + branchName); } + @NotNull + @Override + public GitCommandResult push(@NotNull GitRepository repository, @NotNull String remote, @NotNull String url, @NotNull String spec, + boolean updateTracking, @NotNull GitLineHandlerListener... listeners) { + throw new UnsupportedOperationException(); + } + @NotNull @Override public GitCommandResult push(@NotNull GitRepository repository, @NotNull String remote, @NotNull String url, @NotNull String spec, diff --git a/plugins/github/src/org/jetbrains/plugins/github/GithubShareAction.java b/plugins/github/src/org/jetbrains/plugins/github/GithubShareAction.java index 4403a29276e6..1d596679aece 100644 --- a/plugins/github/src/org/jetbrains/plugins/github/GithubShareAction.java +++ b/plugins/github/src/org/jetbrains/plugins/github/GithubShareAction.java @@ -375,7 +375,7 @@ public class GithubShareAction extends DumbAwareAction { "no current branch"); return false; } - GitCommandResult result = git.push(repository, remoteName, remoteUrl, currentBranch.getName()); + GitCommandResult result = git.push(repository, remoteName, remoteUrl, currentBranch.getName(), true); if (!result.success()) { GithubNotifications.showError(project, "Can't finish GitHub sharing process", "Successfully created project '" + name +