Search in sources :

Example 1 with GitLocalChangesWouldBeOverwrittenDetector

use of git4idea.commands.GitLocalChangesWouldBeOverwrittenDetector in project intellij-community by JetBrains.

the class GitResetOperation method execute.

public void execute() {
    saveAllDocuments();
    AccessToken token = DvcsUtil.workingTreeChangeStarted(myProject);
    Map<GitRepository, GitCommandResult> results = ContainerUtil.newHashMap();
    try {
        for (Map.Entry<GitRepository, Hash> entry : myCommits.entrySet()) {
            GitRepository repository = entry.getKey();
            VirtualFile root = repository.getRoot();
            String target = entry.getValue().asString();
            GitLocalChangesWouldBeOverwrittenDetector detector = new GitLocalChangesWouldBeOverwrittenDetector(root, RESET);
            GitCommandResult result = myGit.reset(repository, myMode, target, detector);
            if (!result.success() && detector.wasMessageDetected()) {
                GitCommandResult smartResult = proposeSmartReset(detector, repository, target);
                if (smartResult != null) {
                    result = smartResult;
                }
            }
            results.put(repository, result);
            repository.update();
            VfsUtil.markDirtyAndRefresh(false, true, false, root);
            VcsDirtyScopeManager.getInstance(myProject).dirDirtyRecursively(root);
        }
    } finally {
        token.finish();
    }
    notifyResult(results);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) GitRepository(git4idea.repo.GitRepository) GitLocalChangesWouldBeOverwrittenDetector(git4idea.commands.GitLocalChangesWouldBeOverwrittenDetector) AccessToken(com.intellij.openapi.application.AccessToken) GitCommandResult(git4idea.commands.GitCommandResult) Hash(com.intellij.vcs.log.Hash) Map(java.util.Map) MultiMap(com.intellij.util.containers.MultiMap)

Aggregations

AccessToken (com.intellij.openapi.application.AccessToken)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 MultiMap (com.intellij.util.containers.MultiMap)1 Hash (com.intellij.vcs.log.Hash)1 GitCommandResult (git4idea.commands.GitCommandResult)1 GitLocalChangesWouldBeOverwrittenDetector (git4idea.commands.GitLocalChangesWouldBeOverwrittenDetector)1 GitRepository (git4idea.repo.GitRepository)1 Map (java.util.Map)1