org.eclipse.jgit.treewalk.WorkingTreeOptions Java Examples
The following examples show how to use
org.eclipse.jgit.treewalk.WorkingTreeOptions.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ResolveMerger.java From onedev with MIT License | 6 votes |
/** * Constructor for ResolveMerger. * * @param local * the {@link org.eclipse.jgit.lib.Repository}. * @param inCore * a boolean. */ protected ResolveMerger(Repository local, boolean inCore) { super(local); Config config = local.getConfig(); mergeAlgorithm = getMergeAlgorithm(config); inCoreLimit = getInCoreLimit(config); commitNames = defaultCommitNames(); this.inCore = inCore; if (inCore) { implicitDirCache = false; dircache = DirCache.newInCore(); } else { implicitDirCache = true; workingTreeOptions = local.getConfig().get(WorkingTreeOptions.KEY); } }
Example #2
Source File: BlameCommand.java From netbeans with Apache License 2.0 | 6 votes |
@Override protected void run () throws GitException { Repository repository = getRepository(); org.eclipse.jgit.api.BlameCommand cmd = new Git(repository).blame(); cmd.setFilePath(Utils.getRelativePath(getRepository().getWorkTree(), file)); if (revision != null) { cmd.setStartCommit(Utils.findCommit(repository, revision)); } else if (repository.getConfig().get(WorkingTreeOptions.KEY).getAutoCRLF() != CoreConfig.AutoCRLF.FALSE) { // work-around for autocrlf cmd.setTextComparator(new AutoCRLFComparator()); } cmd.setFollowFileRenames(true); try { BlameResult cmdResult = cmd.call(); if (cmdResult != null) { result = getClassFactory().createBlameResult(cmdResult, repository); } } catch (GitAPIException ex) { throw new GitException(ex); } }
Example #3
Source File: CheckoutRevisionCommand.java From netbeans with Apache License 2.0 | 5 votes |
private void cacheContents (List<String> conflicts) throws IOException { File workTree = getRepository().getWorkTree(); WorkingTreeOptions opt = getRepository().getConfig().get(WorkingTreeOptions.KEY); boolean autocrlf = opt.getAutoCRLF() != CoreConfig.AutoCRLF.FALSE; try (ObjectInserter inserter = getRepository().newObjectInserter();) { for (String path : conflicts) { File f = new File(workTree, path); Path p = null; try { p = f.toPath(); } catch (InvalidPathException ex) { Logger.getLogger(CheckoutRevisionCommand.class.getName()).log(Level.FINE, null, ex); } if (p != null && Files.isSymbolicLink(p)) { Path link = Utils.getLinkPath(p); cachedContents.put(path, inserter.insert(Constants.OBJ_BLOB, Constants.encode(link.toString()))); } else if (f.isFile()) { long sz = f.length(); try (FileInputStream in = new FileInputStream(f)) { if (autocrlf) { ByteBuffer buf = IO.readWholeStream(in, (int) sz); cachedContents.put(path, inserter.insert(Constants.OBJ_BLOB, buf.array(), buf.position(), buf.limit() - buf.position())); } else { cachedContents.put(path, inserter.insert(Constants.OBJ_BLOB, sz, in)); } } } } inserter.flush(); } }
Example #4
Source File: CheckoutRevisionCommand.java From netbeans with Apache License 2.0 | 5 votes |
private void checkoutFile (MergeResult<RawText> merge, String path) throws IOException { File file = new File(getRepository().getWorkTree(), path); file.getParentFile().mkdirs(); MergeFormatter format = new MergeFormatter(); WorkingTreeOptions opt = getRepository().getConfig().get(WorkingTreeOptions.KEY); try (OutputStream fos = opt.getAutoCRLF() != CoreConfig.AutoCRLF.FALSE ? new AutoCRLFOutputStream(new FileOutputStream(file)) : new FileOutputStream(file)) { format.formatMerge(fos, merge, Arrays.asList(new String[] { "BASE", "OURS", "THEIRS" }), //NOI18N Constants.CHARACTER_ENCODING); } }
Example #5
Source File: GitStagedFiles.java From git-code-format-maven-plugin with MIT License | 5 votes |
private GitStagedFiles(Log log, Repository repository, Set<String> filePaths) { this.log = requireNonNull(log); this.repository = requireNonNull(repository); this.filePaths = Collections.unmodifiableSet(filePaths); WorkingTreeOptions workingTreeOptions = repository.getConfig().get(WorkingTreeOptions.KEY); if (workingTreeOptions.getAutoCRLF() == AutoCRLF.TRUE) { eolStreamType = EolStreamType.AUTO_CRLF; } else { eolStreamType = EolStreamType.DIRECT; } log.debug("eolStreamType is '" + eolStreamType + "'"); }
Example #6
Source File: NoGitignoreIterator.java From writelatex-git-bridge with MIT License | 5 votes |
public NoGitignoreIterator( File root, FS fs, WorkingTreeOptions options, FileModeStrategy fileModeStrategy ) { super(root, fs, options, fileModeStrategy); }
Example #7
Source File: ExportDiffCommand.java From netbeans with Apache License 2.0 | 4 votes |
@Override protected void run() throws GitException { Repository repository = getRepository(); String workTreePath = repository.getWorkTree().getAbsolutePath(); try (DiffFormatter formatter = new DiffFormatter(out); ObjectReader or = repository.newObjectReader()) { formatter.setRepository(repository); Collection<PathFilter> pathFilters = Utils.getPathFilters(repository.getWorkTree(), roots); if (!pathFilters.isEmpty()) { formatter.setPathFilter(PathFilterGroup.create(pathFilters)); } if (repository.getConfig().get(WorkingTreeOptions.KEY).getAutoCRLF() != CoreConfig.AutoCRLF.FALSE) { // work-around for autocrlf formatter.setDiffComparator(new AutoCRLFComparator()); } AbstractTreeIterator firstTree = getIterator(firstCommit, or); AbstractTreeIterator secondTree = getIterator(secondCommit, or); List<DiffEntry> diffEntries; if (secondTree instanceof WorkingTreeIterator) { // remote when fixed in JGit, see ExportDiffTest.testDiffRenameDetectionProblem formatter.setDetectRenames(false); diffEntries = formatter.scan(firstTree, secondTree); formatter.setDetectRenames(true); RenameDetector detector = formatter.getRenameDetector(); detector.reset(); detector.addAll(diffEntries); diffEntries = detector.compute(new ContentSource.Pair(ContentSource.create(or), ContentSource.create((WorkingTreeIterator) secondTree)), NullProgressMonitor.INSTANCE); } else { formatter.setDetectRenames(true); diffEntries = formatter.scan(firstTree, secondTree); } for (DiffEntry ent : diffEntries) { if (monitor.isCanceled()) { break; } listener.notifyFile(new File(workTreePath + File.separator + ent.getNewPath()), ent.getNewPath()); formatter.format(ent); } formatter.flush(); } catch (IOException ex) { throw new GitException(ex); } }
Example #8
Source File: GfsTreeIterator.java From ParallelGit with Apache License 2.0 | 4 votes |
private GfsTreeIterator(List<GfsTreeEntry> files) { super((WorkingTreeOptions) null); this.files = files; next(1); }
Example #9
Source File: GfsTreeIterator.java From ParallelGit with Apache License 2.0 | 4 votes |
private GfsTreeIterator(List<GfsTreeEntry> files) { super((WorkingTreeOptions) null); this.files = files; next(1); }
Example #10
Source File: NoGitignoreIterator.java From writelatex-git-bridge with MIT License | 4 votes |
public NoGitignoreIterator(File root, FS fs, WorkingTreeOptions options) { super(root, fs, options); }