From 818660d1a766c829a455042e751b38ca93b1005e Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Sun, 23 Jun 2019 23:15:20 +0100 Subject: [PATCH] git: remember the previous HEAD position before pull/merge The revision is used to calculate updated files. It used to work, because Repository.getCurrentRevision returns the cached version which is not updated unless explicitly requested and unless a VFS refresh is received indicating that the HEAD file has changed: the first didn't happen, the latter most likely didn't happen as well, but it is just by luck. GitOrigin-RevId: a44a65db4167dc15a459b481702f62cb0c187519 --- .../src/git4idea/actions/GitMergeAction.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/plugins/git4idea/src/git4idea/actions/GitMergeAction.java b/plugins/git4idea/src/git4idea/actions/GitMergeAction.java index c1594f1436e1..cbb2ec8ff703 100644 --- a/plugins/git4idea/src/git4idea/actions/GitMergeAction.java +++ b/plugins/git4idea/src/git4idea/actions/GitMergeAction.java @@ -115,6 +115,8 @@ abstract class GitMergeAction extends GitRepositoryAction { } } + String beforeRevision = repository.getCurrentRevision(); + try (AccessToken ignore = DvcsUtil.workingTreeChangeStarted(project, getActionName())) { GitCommandResult result = git.runCommand(() -> { GitLineHandler handler = handlerProvider.compute(); @@ -124,14 +126,11 @@ abstract class GitMergeAction extends GitRepositoryAction { return handler; }); - String revision = repository.getCurrentRevision(); - if (revision == null) { - return; + if (beforeRevision != null) { + GitRevisionNumber currentRev = new GitRevisionNumber(beforeRevision); + handleResult(result, project, mergeConflict, localChangesDetector, untrackedFilesDetector, repository, currentRev, beforeLabel, + updatedRanges); } - - GitRevisionNumber currentRev = new GitRevisionNumber(revision); - handleResult(result, project, mergeConflict, localChangesDetector, untrackedFilesDetector, repository, currentRev, beforeLabel, - updatedRanges); } } }.queue();