mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[git] Fix "Show Diff", "Show Diff with Local", "Compare with Branch" for directories
Pass the directory itself (otherwise the diff is calculated for the whole repository).
This commit is contained in:
@@ -405,7 +405,7 @@ public final class GitBranchOperationsProcessor {
|
||||
@NotNull
|
||||
private static Collection<Change> 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
|
||||
|
||||
@@ -413,7 +413,8 @@ public class GitChangeUtils {
|
||||
|
||||
@NotNull
|
||||
public static Collection<Change> getDiff(@NotNull Project project, @NotNull VirtualFile root,
|
||||
@NotNull String oldRevision, @Nullable String newRevision) throws VcsException {
|
||||
@NotNull String oldRevision, @Nullable String newRevision,
|
||||
@Nullable Collection<FilePath> 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<Change> changes = new ArrayList<Change>();
|
||||
parseChanges(project, root, newRev, loadRevision(project, root, oldRevision), output, changes, Collections.<String>emptySet());
|
||||
|
||||
@@ -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<List<Change>>() {
|
||||
calculateDiffInBackground(repository, path, hash1, hash2, new Consumer<List<Change>>() {
|
||||
@Override
|
||||
public void consume(List<Change> 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<List<Change>> successHandler) {
|
||||
new Task.Backgroundable(myProject, "Comparing revisions...") {
|
||||
private List<Change> myChanges;
|
||||
@Override
|
||||
public void run(@NotNull ProgressIndicator indicator) {
|
||||
try {
|
||||
myChanges = new ArrayList<Change>(GitChangeUtils.getDiff(repository.getProject(), repository.getRoot(), hash1, hash2));
|
||||
myChanges = new ArrayList<Change>(GitChangeUtils.getDiff(repository.getProject(), repository.getRoot(), hash1, hash2,
|
||||
Collections.singletonList(path)));
|
||||
}
|
||||
catch (VcsException e) {
|
||||
showError(e, "Error during requesting diff for directory");
|
||||
|
||||
Reference in New Issue
Block a user