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
This commit is contained in:
Kirill Likhodedov
2019-07-02 06:52:16 +03:00
committed by intellij-monorepo-bot
parent f8b51e1906
commit 818660d1a7
@@ -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();