List of usage examples for org.eclipse.jgit.api RmCommand setCached
public RmCommand setCached(boolean cached)
From source file:org.eclipse.che.git.impl.jgit.JGitConnection.java
License:Open Source License
@Override public void rm(RmRequest request) throws GitException { List<String> files = request.getItems(); RmCommand rmCommand = getGit().rm(); rmCommand.setCached(request.isCached()); if (files != null) { files.forEach(rmCommand::addFilepattern); }//from w ww . ja v a 2 s .c o m try { rmCommand.call(); } catch (GitAPIException exception) { throw new GitException(exception.getMessage(), exception); } }
From source file:org.eclipse.egit.core.op.RemoveFromIndexOperation.java
License:Open Source License
private static GitCommand<?> prepareCommand(Repository repository, Collection<String> paths) { Git git = new Git(repository); if (hasHead(repository)) { ResetCommand resetCommand = git.reset(); resetCommand.setRef(HEAD);/*from w w w.j a v a2s. c om*/ for (String path : paths) resetCommand.addPath(getCommandPath(path)); return resetCommand; } else { RmCommand rmCommand = git.rm(); rmCommand.setCached(true); for (String path : paths) rmCommand.addFilepattern(getCommandPath(path)); return rmCommand; } }
From source file:org.eclipse.ptp.internal.rdt.sync.git.core.GitSyncFileFilter.java
License:Open Source License
@Override public void saveFilter() throws IOException { Repository repo = jgitRepo.getRepository(); File exclude = repo.getFS().resolve(repo.getDirectory(), Constants.INFO_EXCLUDE); exclude.getParentFile().mkdirs();/*ww w . j av a2 s . c o m*/ FileOutputStream file = new FileOutputStream(exclude); BufferedWriter out = new BufferedWriter(new OutputStreamWriter(file, Constants.CHARSET)); try { for (AbstractIgnoreRule rule : rules) { out.write(rule.toString()); out.newLine(); } } finally { out.close(); } final RmCommand rmCommand = new RmCommand(repo); rmCommand.setCached(true); for (String fileName : getIgnoredFiles(null)) { rmCommand.addFilepattern(fileName); } try { rmCommand.call(); } catch (NoFilepatternException e) { new IOException(e); // TODO: a bit ugly to wrap it into IOExcpetion } catch (GitAPIException e) { new IOException(e); } }
From source file:org.eclipse.ptp.internal.rdt.sync.git.core.JGitRepo.java
License:Open Source License
/** * Commit files in working directory./*from ww w . j a va 2 s.c om*/ * * assumes that no files are in conflict (do not call during merge) * * @param monitor * * @return whether any changes were committed * @throws GitAPIException * on JGit-specific problems * @throws IOException * on file system problems */ public boolean commit(IProgressMonitor monitor) throws GitAPIException, IOException { RecursiveSubMonitor subMon = RecursiveSubMonitor.convert(monitor, 10); assert (!inUnresolvedMergeState()); try { DiffFiles diffFiles = fileFilter.getDiffFiles(); // Create and add an empty file to all synchronized directories to force sync'ing of empty directories for (String dirName : diffFiles.dirSet) { IPath emptyFilePath = new Path(this.getRepository().getWorkTree().getAbsolutePath()); emptyFilePath = emptyFilePath.append(dirName); // Bug 439609 - directory may have been deleted File emptyFileDir = new File(emptyFilePath.toOSString()); if (!emptyFileDir.exists()) { continue; } emptyFilePath = emptyFilePath.append(EMPTY_FILE_NAME); File emptyFile = new File(emptyFilePath.toOSString()); boolean fileWasCreated = emptyFile.createNewFile(); if (fileWasCreated) { diffFiles.added.add(emptyFilePath.toString()); } } subMon.subTask(Messages.JGitRepo_2); if (!diffFiles.added.isEmpty()) { final AddCommand addCommand = git.add(); //Bug 401161 doesn't matter here because files are already filtered anyhow. It would be OK //if the tree iterator would always return false in isEntryIgnored addCommand.setWorkingTreeIterator(new SyncFileTreeIterator(git.getRepository(), fileFilter)); for (String fileName : diffFiles.added) { addCommand.addFilepattern(fileName); } addCommand.call(); } subMon.worked(3); subMon.subTask(Messages.JGitRepo_3); if (!diffFiles.removed.isEmpty()) { final RmCommand rmCommand = new RmCommand(git.getRepository()); rmCommand.setCached(true); for (String fileName : diffFiles.removed) { rmCommand.addFilepattern(fileName); } rmCommand.call(); } subMon.worked(3); // Check if a commit is required. subMon.subTask(Messages.JGitRepo_4); if (anyDiffInIndex() || inMergeState()) { final CommitCommand commitCommand = git.commit(); commitCommand.setMessage(GitSyncService.commitMessage); commitCommand.call(); return true; } else { return false; } } finally { if (monitor != null) { monitor.done(); } } }