diff --git a/plugins/git4idea/src/git4idea/branch/GitBranchPair.kt b/plugins/git4idea/src/git4idea/branch/GitBranchPair.kt index 5614546420e6..84db24c57d6e 100644 --- a/plugins/git4idea/src/git4idea/branch/GitBranchPair.kt +++ b/plugins/git4idea/src/git4idea/branch/GitBranchPair.kt @@ -21,4 +21,4 @@ import git4idea.GitRemoteBranch /** * Holder for Git branch and the branch it is "connected" with. It is tracked branch or so called "matched" branch. */ -data class GitBranchPair(val source: GitLocalBranch, val target: GitRemoteBranch?) +data class GitBranchPair(val source: GitLocalBranch, val target: GitRemoteBranch) diff --git a/plugins/git4idea/src/git4idea/update/GitMergeUpdater.java b/plugins/git4idea/src/git4idea/update/GitMergeUpdater.java index 2bc848837dd1..eb6ebb8ac501 100644 --- a/plugins/git4idea/src/git4idea/update/GitMergeUpdater.java +++ b/plugins/git4idea/src/git4idea/update/GitMergeUpdater.java @@ -33,7 +33,6 @@ import org.jetbrains.annotations.NotNull; import java.io.File; import java.util.*; -import static com.intellij.util.ObjectUtils.assertNotNull; import static java.util.Arrays.asList; /** @@ -68,7 +67,7 @@ public class GitMergeUpdater extends GitUpdater { String originalText = myProgressIndicator.getText(); myProgressIndicator.setText("Merging" + GitUtil.mention(myRepository) + "..."); try { - GitCommandResult result = myGit.merge(myRepository, assertNotNull(myBranchPair.getTarget()).getName(), + GitCommandResult result = myGit.merge(myRepository, myBranchPair.getTarget().getName(), asList("--no-stat", "-v"), mergeLineListener, untrackedFilesDetector, GitStandardProgressAnalyzer.createListener(myProgressIndicator)); myProgressIndicator.setText(originalText); diff --git a/plugins/git4idea/src/git4idea/update/GitRebaseUpdater.java b/plugins/git4idea/src/git4idea/update/GitRebaseUpdater.java index dbee1710fc8b..b7f4b07a9ddb 100644 --- a/plugins/git4idea/src/git4idea/update/GitRebaseUpdater.java +++ b/plugins/git4idea/src/git4idea/update/GitRebaseUpdater.java @@ -12,7 +12,6 @@ import com.intellij.openapi.vcs.changes.ChangeListManager; import com.intellij.openapi.vcs.impl.LocalChangesUnderRoots; import com.intellij.openapi.vcs.update.UpdatedFiles; import com.intellij.util.containers.ContainerUtil; -import git4idea.GitBranch; import git4idea.GitUtil; import git4idea.branch.GitBranchPair; import git4idea.commands.Git; @@ -74,10 +73,7 @@ public class GitRebaseUpdater extends GitUpdater { @NotNull private String getRemoteBranchToMerge() { - GitBranch dest = myBranchPair.getTarget(); - LOG.assertTrue(dest != null, String.format("Destination branch is null for source branch %s in %s", - myBranchPair.getSource().getName(), myRoot)); - return dest.getName(); + return myBranchPair.getTarget().getName(); } public void cancel() { diff --git a/plugins/git4idea/src/git4idea/update/GitUpdateProcess.java b/plugins/git4idea/src/git4idea/update/GitUpdateProcess.java index 0c7e0765be18..a03ea2a20e28 100644 --- a/plugins/git4idea/src/git4idea/update/GitUpdateProcess.java +++ b/plugins/git4idea/src/git4idea/update/GitUpdateProcess.java @@ -47,7 +47,6 @@ import org.jetbrains.annotations.Nullable; import java.util.*; import static com.intellij.dvcs.DvcsUtil.getShortRepositoryName; -import static com.intellij.util.ObjectUtils.assertNotNull; import static git4idea.GitUtil.getRootsFromRepositories; import static git4idea.GitUtil.mention; import static git4idea.fetch.GitFetchSupport.fetchSupport; @@ -266,8 +265,9 @@ public class GitUpdateProcess { return ContainerUtil.mapNotNull(updaters.keySet(), repo -> { GitUpdater updater = updaters.get(repo); if (updater instanceof GitRebaseUpdater) { - String currentRef = ((GitRebaseUpdater)updater).getSourceAndTarget().getSource().getFullName(); - String baseRef = assertNotNull(((GitRebaseUpdater)updater).getSourceAndTarget().getTarget()).getFullName(); + GitBranchPair sourceAndTarget = ((GitRebaseUpdater)updater).getSourceAndTarget(); + String currentRef = sourceAndTarget.getSource().getFullName(); + String baseRef = sourceAndTarget.getTarget().getFullName(); return GitRebaseOverMergeProblem.hasProblem(myProject, repo.getRoot(), baseRef, currentRef) ? repo : null; } return null; diff --git a/plugins/git4idea/src/git4idea/update/GitUpdater.java b/plugins/git4idea/src/git4idea/update/GitUpdater.java index f2dc542d64aa..e165aa5ca208 100644 --- a/plugins/git4idea/src/git4idea/update/GitUpdater.java +++ b/plugins/git4idea/src/git4idea/update/GitUpdater.java @@ -166,9 +166,7 @@ public abstract class GitUpdater { * @return true if update is needed, false otherwise. */ public boolean isUpdateNeeded(@NotNull GitBranchPair branchPair) throws VcsException { - GitBranch dest = branchPair.getTarget(); - assert dest != null; - String remoteBranch = dest.getName(); + String remoteBranch = branchPair.getTarget().getName(); if (!hasRemoteChanges(remoteBranch)) { LOG.info("isUpdateNeeded: No remote changes, update is not needed"); return false;