diff --git a/plugins/git4idea/src/git4idea/branch/GitBranchOperationsProcessor.java b/plugins/git4idea/src/git4idea/branch/GitBranchOperationsProcessor.java index 0b76583eb7af..c8c354d1738f 100644 --- a/plugins/git4idea/src/git4idea/branch/GitBranchOperationsProcessor.java +++ b/plugins/git4idea/src/git4idea/branch/GitBranchOperationsProcessor.java @@ -405,7 +405,7 @@ public final class GitBranchOperationsProcessor { @NotNull private static Collection loadTotalDiff(@NotNull GitRepository repository, @NotNull String branchName) { try { - return GitChangeUtils.getDiff(repository.getProject(), repository.getRoot(), "HEAD", branchName); + return GitChangeUtils.getDiff(repository.getProject(), repository.getRoot(), "HEAD", branchName, null); } catch (VcsException e) { // we treat it as critical and report an error diff --git a/plugins/git4idea/src/git4idea/changes/GitChangeUtils.java b/plugins/git4idea/src/git4idea/changes/GitChangeUtils.java index 3347e3b2a6d9..d6e9f92de9b2 100644 --- a/plugins/git4idea/src/git4idea/changes/GitChangeUtils.java +++ b/plugins/git4idea/src/git4idea/changes/GitChangeUtils.java @@ -413,7 +413,8 @@ public class GitChangeUtils { @NotNull public static Collection getDiff(@NotNull Project project, @NotNull VirtualFile root, - @NotNull String oldRevision, @Nullable String newRevision) throws VcsException { + @NotNull String oldRevision, @Nullable String newRevision, + @Nullable Collection dirtyPaths) throws VcsException { String range; GitRevisionNumber newRev; if (newRevision == null) { @@ -425,7 +426,7 @@ public class GitChangeUtils { range = oldRevision + ".." + newRevision; newRev = loadRevision(project, root, newRevision); } - String output = getDiffOutput(project, root, range, null); + String output = getDiffOutput(project, root, range, dirtyPaths); Collection changes = new ArrayList(); parseChanges(project, root, newRev, loadRevision(project, root, oldRevision), output, changes, Collections.emptySet()); diff --git a/plugins/git4idea/src/git4idea/history/GitDiffFromHistoryHandler.java b/plugins/git4idea/src/git4idea/history/GitDiffFromHistoryHandler.java index fe44b1cdd4b5..f73337d5266c 100644 --- a/plugins/git4idea/src/git4idea/history/GitDiffFromHistoryHandler.java +++ b/plugins/git4idea/src/git4idea/history/GitDiffFromHistoryHandler.java @@ -32,7 +32,10 @@ import com.intellij.openapi.vcs.FilePath; import com.intellij.openapi.vcs.VcsException; import com.intellij.openapi.vcs.changes.Change; import com.intellij.openapi.vcs.changes.ui.ChangesBrowser; -import com.intellij.openapi.vcs.history.*; +import com.intellij.openapi.vcs.history.CurrentRevision; +import com.intellij.openapi.vcs.history.DiffFromHistoryHandler; +import com.intellij.openapi.vcs.history.VcsFileRevision; +import com.intellij.openapi.vcs.history.VcsHistoryUtil; import com.intellij.openapi.vcs.ui.VcsBalloonProblemNotifier; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.ui.awt.RelativePoint; @@ -52,6 +55,7 @@ import org.jetbrains.annotations.Nullable; import java.awt.event.MouseEvent; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; @@ -118,7 +122,7 @@ public class GitDiffFromHistoryHandler implements DiffFromHistoryHandler { private void showDiffForDirectory(@NotNull final FilePath path, @NotNull final String hash1, @Nullable final String hash2) { GitRepository repository = getRepository(path); - calculateDiffInBackground(repository, hash1, hash2, new Consumer>() { + calculateDiffInBackground(repository, path, hash1, hash2, new Consumer>() { @Override public void consume(List changes) { showDirDiffDialog(path, hash1, hash2, changes); @@ -135,14 +139,16 @@ public class GitDiffFromHistoryHandler implements DiffFromHistoryHandler { return repository; } - private void calculateDiffInBackground(@NotNull final GitRepository repository, final String hash1, @Nullable final String hash2, + private void calculateDiffInBackground(@NotNull final GitRepository repository, @NotNull final FilePath path, + @NotNull final String hash1, @Nullable final String hash2, final Consumer> successHandler) { new Task.Backgroundable(myProject, "Comparing revisions...") { private List myChanges; @Override public void run(@NotNull ProgressIndicator indicator) { try { - myChanges = new ArrayList(GitChangeUtils.getDiff(repository.getProject(), repository.getRoot(), hash1, hash2)); + myChanges = new ArrayList(GitChangeUtils.getDiff(repository.getProject(), repository.getRoot(), hash1, hash2, + Collections.singletonList(path))); } catch (VcsException e) { showError(e, "Error during requesting diff for directory");