Search in sources :

Example 26 with GitSimpleHandler

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

the class GitRollbackEnvironment method resetHardLocal.

public static void resetHardLocal(final Project project, final VirtualFile root) {
    GitSimpleHandler handler = new GitSimpleHandler(project, root, GitCommand.RESET);
    handler.addParameters("--hard");
    handler.endOptions();
    GitHandlerUtil.runInCurrentThread(handler, null);
}
Also used : GitSimpleHandler(git4idea.commands.GitSimpleHandler)

Example 27 with GitSimpleHandler

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

the class GitNewChangesCollector method collectChanges.

// calls 'git status' and parses the output, feeding myChanges.
private void collectChanges(Collection<FilePath> dirtyPaths) throws VcsException {
    GitSimpleHandler handler = statusHandler(dirtyPaths);
    String output = handler.run();
    parseOutput(output, handler);
}
Also used : GitSimpleHandler(git4idea.commands.GitSimpleHandler)

Example 28 with GitSimpleHandler

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

the class GitNewChangesCollector method statusHandler.

private GitSimpleHandler statusHandler(Collection<FilePath> dirtyPaths) {
    GitSimpleHandler handler = new GitSimpleHandler(myProject, myVcsRoot, GitCommand.STATUS);
    // untracked files are stored separately
    final String[] params = { "--porcelain", "-z", "--untracked-files=no" };
    handler.addParameters(params);
    handler.endOptions();
    handler.addRelativePaths(dirtyPaths);
    if (handler.isLargeCommandLine()) {
        // if there are too much files, just get all changes for the project
        handler = new GitSimpleHandler(myProject, myVcsRoot, GitCommand.STATUS);
        handler.addParameters(params);
        handler.endOptions();
    }
    handler.setSilent(true);
    return handler;
}
Also used : GitSimpleHandler(git4idea.commands.GitSimpleHandler)

Example 29 with GitSimpleHandler

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

the class GitOldChangesCollector method collectUnmergedAndUnversioned.

/**
   * Collect unversioned and unmerged files
   *
   * @throws VcsException if there is a problem with running git
   */
private void collectUnmergedAndUnversioned() throws VcsException {
    Collection<FilePath> dirtyPaths = dirtyPaths(false);
    if (dirtyPaths.isEmpty()) {
        return;
    }
    // prepare handler
    GitSimpleHandler handler = new GitSimpleHandler(myProject, myVcsRoot, GitCommand.LS_FILES);
    handler.addParameters("-v", "--unmerged");
    handler.setSilent(true);
    handler.setStdoutSuppressed(true);
    // run handler and collect changes
    parseFiles(handler.run());
    // prepare handler
    handler = new GitSimpleHandler(myProject, myVcsRoot, GitCommand.LS_FILES);
    handler.addParameters("-v", "--others", "--exclude-standard");
    handler.setSilent(true);
    handler.setStdoutSuppressed(true);
    handler.endOptions();
    handler.addRelativePaths(dirtyPaths);
    if (handler.isLargeCommandLine()) {
        handler = new GitSimpleHandler(myProject, myVcsRoot, GitCommand.LS_FILES);
        handler.addParameters("-v", "--others", "--exclude-standard");
        handler.setSilent(true);
        handler.setStdoutSuppressed(true);
        handler.endOptions();
    }
    // run handler and collect changes
    parseFiles(handler.run());
}
Also used : GitSimpleHandler(git4idea.commands.GitSimpleHandler)

Example 30 with GitSimpleHandler

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

the class GitAnnotationProvider method doAnnotate.

@NotNull
private GitFileAnnotation doAnnotate(@NotNull final FilePath repositoryFilePath, @Nullable final VcsRevisionNumber revision, @NotNull final VirtualFile file) throws VcsException {
    setProgressIndicatorText(GitBundle.message("computing.annotation", file.getName()));
    VirtualFile root = GitUtil.getGitRoot(repositoryFilePath);
    GitSimpleHandler h = new GitSimpleHandler(myProject, root, GitCommand.BLAME);
    h.setStdoutSuppressed(true);
    h.addParameters("--porcelain", "-l", "-t", "-w");
    if (revision == null) {
        h.addParameters("HEAD");
    } else {
        h.addParameters(revision.asString());
    }
    h.endOptions();
    h.addRelativePaths(repositoryFilePath);
    String output = h.run();
    GitFileAnnotation fileAnnotation = parseAnnotations(revision, file, root, output);
    loadFileHistoryInBackground(fileAnnotation);
    return fileAnnotation;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VcsVirtualFile(com.intellij.openapi.vcs.vfs.VcsVirtualFile) GitSimpleHandler(git4idea.commands.GitSimpleHandler) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

GitSimpleHandler (git4idea.commands.GitSimpleHandler)42 NotNull (org.jetbrains.annotations.NotNull)10 VcsException (com.intellij.openapi.vcs.VcsException)8 VirtualFile (com.intellij.openapi.vfs.VirtualFile)6 ObjectUtils.assertNotNull (com.intellij.util.ObjectUtils.assertNotNull)6 StringScanner (git4idea.util.StringScanner)5 FilePath (com.intellij.openapi.vcs.FilePath)3 Change (com.intellij.openapi.vcs.changes.Change)3 GitRevisionNumber (git4idea.GitRevisionNumber)3 File (java.io.File)3 Nullable (org.jetbrains.annotations.Nullable)3 GitUtil.getLogString (git4idea.GitUtil.getLogString)2 GitRepositoryManager (git4idea.repo.GitRepositoryManager)2 Couple (com.intellij.openapi.util.Couple)1 Pair (com.intellij.openapi.util.Pair)1 Ref (com.intellij.openapi.util.Ref)1 SelectFilePathsDialog (com.intellij.openapi.vcs.changes.ui.SelectFilePathsDialog)1 VcsVirtualFile (com.intellij.openapi.vcs.vfs.VcsVirtualFile)1 Convertor (com.intellij.util.containers.Convertor)1 GitBranch (git4idea.GitBranch)1