From 637a8ff7a483d298146a3bbd050f77b4492f01f2 Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Fri, 22 Jun 2012 14:08:45 +0400 Subject: [PATCH] [git] IDEA-87709 Take files updated via git merge --ff-only into account and show them in the updated files info. Caused by the fix for IDEA-87609. --- .../src/git4idea/update/GitRebaseUpdater.java | 26 +++++++++++++++++++ .../src/git4idea/update/GitUpdateProcess.java | 7 ++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/plugins/git4idea/src/git4idea/update/GitRebaseUpdater.java b/plugins/git4idea/src/git4idea/update/GitRebaseUpdater.java index 7dcf1ab17c60..8bb67a7e9f52 100644 --- a/plugins/git4idea/src/git4idea/update/GitRebaseUpdater.java +++ b/plugins/git4idea/src/git4idea/update/GitRebaseUpdater.java @@ -26,6 +26,7 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.ui.UIUtil; import git4idea.GitBranch; import git4idea.GitUtil; +import git4idea.Notificator; import git4idea.PlatformFacade; import git4idea.branch.GitBranchPair; import git4idea.commands.*; @@ -170,6 +171,10 @@ public class GitRebaseUpdater extends GitUpdater { return "Rebase updater"; } + /** + * Tries to execute {@code git merge --ff-only}. + * @return true, if everything is successful; false for any error (to let a usual "fair" update deal with it). + */ public boolean fastForwardMerge() { LOG.info("Trying fast-forward merge for " + myRoot); GitRepository repository = GitUtil.getRepositoryManager(myProject).getRepositoryForRoot(myRoot); @@ -177,7 +182,28 @@ public class GitRebaseUpdater extends GitUpdater { LOG.error("Repository is null for " + myRoot); return false; } + try { + markStart(myRoot); + } + catch (VcsException e) { + LOG.info("Couldn't mark start for repository " + myRoot, e); + return false; + } + GitCommandResult result = myGit.merge(repository, getRemoteBranchToMerge(), Collections.singletonList("--ff-only")); + + try { + markEnd(myRoot); + } + catch (VcsException e) { + // this is not critical, and update has already happened, + // so we just notify the user about problems with collecting the updated changes. + LOG.info("Couldn't mark end for repository " + myRoot, e); + Notificator.getInstance(myProject). + notifyWeakWarning("Couldn't collect the updated files info", + String.format("Update of %s was successful, but we couldn't collect the updated changes because of an error", + myRoot), null); + } return result.success(); } diff --git a/plugins/git4idea/src/git4idea/update/GitUpdateProcess.java b/plugins/git4idea/src/git4idea/update/GitUpdateProcess.java index 8ff7f9dc0049..470a55eaa37f 100644 --- a/plugins/git4idea/src/git4idea/update/GitUpdateProcess.java +++ b/plugins/git4idea/src/git4idea/update/GitUpdateProcess.java @@ -144,10 +144,15 @@ public class GitUpdateProcess { return GitUpdateResult.ERROR; } + if (updaters.isEmpty()) { + return GitUpdateResult.NOTHING_TO_UPDATE; + } + updaters = tryFastForwardMergeForRebaseUpdaters(updaters); if (updaters.isEmpty()) { - return GitUpdateResult.NOTHING_TO_UPDATE; + // everything was updated via the fast-forward merge + return GitUpdateResult.SUCCESS; } // save local changes if needed (update via merge may perform without saving).