use of git4idea.commands.GitSimpleHandler in project intellij-community by JetBrains.
the class GitRollbackEnvironment method revert.
/**
* Reverts the list of files we are passed.
*
* @param root the VCS root
* @param files The array of files to revert.
* @throws VcsException Id it breaks.
*/
public void revert(final VirtualFile root, final List<FilePath> files) throws VcsException {
for (List<String> paths : VcsFileUtil.chunkPaths(root, files)) {
GitSimpleHandler handler = new GitSimpleHandler(myProject, root, GitCommand.CHECKOUT);
handler.addParameters("HEAD");
handler.endOptions();
handler.addParameters(paths);
handler.run();
}
}
use of git4idea.commands.GitSimpleHandler in project intellij-community by JetBrains.
the class MergeChangeCollector method getUnmergedPaths.
/**
* Returns absolute paths to files which are currently unmerged, and also populates myUnmergedPaths with relative paths.
*/
@NotNull
public Set<String> getUnmergedPaths() throws VcsException {
String root = myRoot.getPath();
final GitSimpleHandler h = new GitSimpleHandler(myProject, myRoot, GitCommand.LS_FILES);
h.setSilent(true);
h.addParameters("--unmerged");
final String result = h.run();
final Set<String> paths = new HashSet<>();
for (StringScanner s = new StringScanner(result); s.hasMoreData(); ) {
if (s.isEol()) {
s.nextLine();
continue;
}
s.boundedToken('\t');
final String relative = s.line();
if (!myUnmergedPaths.add(relative)) {
continue;
}
String path = root + "/" + GitUtil.unescapePath(relative);
paths.add(path);
}
return paths;
}
use of git4idea.commands.GitSimpleHandler in project intellij-community by JetBrains.
the class GitStashUtils method loadStashStack.
public static void loadStashStack(@NotNull Project project, @NotNull VirtualFile root, @NotNull Charset charset, final Consumer<StashInfo> consumer) {
GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.STASH.readLockingCommand());
h.setSilent(true);
h.addParameters("list");
String out;
try {
h.setCharset(charset);
out = h.run();
} catch (VcsException e) {
GitUIUtil.showOperationError(project, e, h.printableCommandLine());
return;
}
for (StringScanner s = new StringScanner(out); s.hasMoreData(); ) {
consumer.consume(new StashInfo(s.boundedToken(':'), s.boundedToken(':'), s.line().trim()));
}
}
use of git4idea.commands.GitSimpleHandler in project intellij-community by JetBrains.
the class GitOldChangesCollector method collectDiffChanges.
/**
* Collect diff with head
*
* @throws VcsException if there is a problem with running git
*/
private void collectDiffChanges() throws VcsException {
Collection<FilePath> dirtyPaths = dirtyPaths(true);
if (dirtyPaths.isEmpty()) {
return;
}
try {
String output = GitChangeUtils.getDiffOutput(myProject, myVcsRoot, "HEAD", dirtyPaths);
GitChangeUtils.parseChanges(myProject, myVcsRoot, null, GitChangeUtils.resolveReference(myProject, myVcsRoot, "HEAD"), output, myChanges, myUnmergedNames);
} catch (VcsException ex) {
if (!GitChangeUtils.isHeadMissing(ex)) {
throw ex;
}
GitSimpleHandler handler = new GitSimpleHandler(myProject, myVcsRoot, GitCommand.LS_FILES);
handler.addParameters("--cached");
handler.setSilent(true);
handler.setStdoutSuppressed(true);
// During init diff does not works because HEAD
// will appear only after the first commit.
// In that case added files are cached in index.
String output = handler.run();
if (output.length() > 0) {
StringTokenizer tokenizer = new StringTokenizer(output, "\n\r");
while (tokenizer.hasMoreTokens()) {
final String s = tokenizer.nextToken();
Change ch = new Change(null, GitContentRevision.createRevision(myVcsRoot, s, null, myProject, false, false, true), FileStatus.ADDED);
myChanges.add(ch);
}
}
}
}
use of git4idea.commands.GitSimpleHandler in project intellij-community by JetBrains.
the class GitOldChangesCollector method updateIndex.
private void updateIndex() throws VcsException {
GitSimpleHandler handler = new GitSimpleHandler(myProject, myVcsRoot, GitCommand.UPDATE_INDEX);
handler.addParameters("--refresh", "--ignore-missing");
handler.setSilent(true);
handler.setStdoutSuppressed(true);
handler.ignoreErrorCode(1);
handler.run();
}
Aggregations