git: cleanup: mark the property as notnull, since it is actually never null

GitOrigin-RevId: 8c2b7a41c7a8067d17da3e79bc3075852108e0ed
This commit is contained in:
Kirill Likhodedov
2019-06-09 15:07:50 +03:00
committed by intellij-monorepo-bot
parent 95a7c1238f
commit d922267423
5 changed files with 7 additions and 14 deletions
@@ -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)
@@ -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);
@@ -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() {
@@ -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;
@@ -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;