diff --git a/plugins/git4idea/src/git4idea/GitUtil.java b/plugins/git4idea/src/git4idea/GitUtil.java index 9ec8058cbe5a..d2bd20b8d4f8 100644 --- a/plugins/git4idea/src/git4idea/GitUtil.java +++ b/plugins/git4idea/src/git4idea/GitUtil.java @@ -331,7 +331,7 @@ public class GitUtil { * @deprecated because uses the java.io.File. * @use GitRepositoryManager#getRepositoryForFile(). */ - public static VirtualFile getGitRoot(final FilePath filePath) throws VcsException { + public static VirtualFile getGitRoot(@NotNull FilePath filePath) throws VcsException { VirtualFile root = getGitRootOrNull(filePath); if (root != null) { return root; diff --git a/plugins/git4idea/src/git4idea/history/GitHistoryUtils.java b/plugins/git4idea/src/git4idea/history/GitHistoryUtils.java index 1affd9ced01d..a3b3196c374e 100644 --- a/plugins/git4idea/src/git4idea/history/GitHistoryUtils.java +++ b/plugins/git4idea/src/git4idea/history/GitHistoryUtils.java @@ -21,6 +21,7 @@ import com.intellij.openapi.progress.ProcessCanceledException; import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.*; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vcs.FilePath; import com.intellij.openapi.vcs.FilePathImpl; import com.intellij.openapi.vcs.FileStatus; @@ -105,18 +106,15 @@ public class GitHistoryUtils { } @Nullable - public static VcsRevisionNumber getCurrentRevision(final Project project, FilePath filePath, @Nullable String branch, final boolean shortHash) throws VcsException { + public static VcsRevisionNumber getCurrentRevision(@NotNull Project project, @NotNull FilePath filePath, @Nullable String branch, + final boolean shortHash) throws VcsException { filePath = getLastCommitName(project, filePath); GitSimpleHandler h = new GitSimpleHandler(project, GitUtil.getGitRoot(filePath), GitCommand.LOG); GitLogParser parser = shortHash ? new GitLogParser(project, SHORT_HASH, COMMIT_TIME) : new GitLogParser(project, HASH, COMMIT_TIME); h.setNoSSH(true); h.setSilent(true); h.addParameters("-n1", parser.getPretty()); - if (branch != null && !branch.isEmpty()) { - h.addParameters(branch); - } else { - h.addParameters("--all"); - } + h.addParameters(!StringUtil.isEmpty(branch) ? branch : "--all"); h.endOptions(); h.addRelativePaths(filePath); String result = h.run(); @@ -912,7 +910,7 @@ public class GitHistoryUtils { * @param path the path to check * @return the name of file in the last commit or argument */ - public static FilePath getLastCommitName(final Project project, FilePath path) { + public static FilePath getLastCommitName(@NotNull Project project, FilePath path) { if (project.isDefault()) return path; final ChangeListManager changeManager = ChangeListManager.getInstance(project); final Change change = changeManager.getChange(path);