Java Code Examples for org.eclipse.jgit.dircache.DirCacheCheckout#checkoutEntry()
The following examples show how to use
org.eclipse.jgit.dircache.DirCacheCheckout#checkoutEntry() .
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 |
private void checkout() throws NoWorkTreeException, IOException { // Iterate in reverse so that "folder/file" is deleted before // "folder". Otherwise this could result in a failing path because // of a non-empty directory, for which delete() would fail. for (int i = toBeDeleted.size() - 1; i >= 0; i--) { String fileName = toBeDeleted.get(i); File f = new File(nonNullRepo().getWorkTree(), fileName); if (!f.delete()) if (!f.isDirectory()) failingPaths.put(fileName, MergeFailureReason.COULD_NOT_DELETE); modifiedFiles.add(fileName); } for (Map.Entry<String, DirCacheEntry> entry : toBeCheckedOut .entrySet()) { DirCacheEntry cacheEntry = entry.getValue(); if (cacheEntry.getFileMode() == FileMode.GITLINK) { new File(nonNullRepo().getWorkTree(), entry.getKey()).mkdirs(); } else { DirCacheCheckout.checkoutEntry(db, cacheEntry, reader, false, checkoutMetadata.get(entry.getKey())); modifiedFiles.add(entry.getKey()); } } }
Example 2
Source File: ResolveMerger.java From onedev with MIT License | 6 votes |
/** * Reverts the worktree after an unsuccessful merge. We know that for all * modified files the old content was in the old index and the index * contained only stage 0. In case if inCore operation just clear the * history of modified files. * * @throws java.io.IOException * @throws org.eclipse.jgit.errors.CorruptObjectException * @throws org.eclipse.jgit.errors.NoWorkTreeException * @since 3.4 */ protected void cleanUp() throws NoWorkTreeException, CorruptObjectException, IOException { if (inCore) { modifiedFiles.clear(); return; } DirCache dc = nonNullRepo().readDirCache(); Iterator<String> mpathsIt=modifiedFiles.iterator(); while(mpathsIt.hasNext()) { String mpath = mpathsIt.next(); DirCacheEntry entry = dc.getEntry(mpath); if (entry != null) { DirCacheCheckout.checkoutEntry(db, entry, reader, false, checkoutMetadata.get(mpath)); } mpathsIt.remove(); } }
Example 3
Source File: CheckoutIndex.java From netbeans with Apache License 2.0 | 5 votes |
public void checkoutEntry (Repository repository, File file, DirCacheEntry e, ObjectReader od) throws IOException, GitException { // ... create/overwrite this file ... if (!ensureParentFolderExists(file.getParentFile())) { return; } boolean exists = file.exists(); if (exists && e.getFileMode() == FileMode.SYMLINK) { monitor.notifyWarning(MessageFormat.format(Utils.getBundle(CheckoutIndex.class).getString("MSG_Warning_SymLink"), file.getAbsolutePath())); //NOI18N return; } if (Utils.isFromNested(e.getFileMode().getBits())) { if (!exists) { file.mkdirs(); } } else { if (exists && file.isDirectory()) { monitor.notifyWarning(MessageFormat.format(Utils.getBundle(CheckoutIndex.class).getString("MSG_Warning_ReplacingDirectory"), file.getAbsolutePath())); //NOI18N Utils.deleteRecursively(file); } file.createNewFile(); if (file.isFile()) { DirCacheCheckout.checkoutEntry(repository, e, od); } else { monitor.notifyError(MessageFormat.format(Utils.getBundle(CheckoutIndex.class).getString("MSG_Warning_CannotCreateFile"), file.getAbsolutePath())); //NOI18N } } }
Example 4
Source File: CheckoutTest.java From netbeans with Apache License 2.0 | 5 votes |
public void testLargeFile () throws Exception { unpack("large.dat.zip"); File large = new File(workDir, "large.dat"); assertTrue(large.exists()); assertEquals(2158310, large.length()); add(); DirCache cache = repository.readDirCache(); DirCacheEntry e = cache.getEntry("large.dat"); WindowCacheConfig cfg = new WindowCacheConfig(); cfg.setStreamFileThreshold((int) large.length() - 1); cfg.install(); DirCacheCheckout.checkoutEntry(repository, e, repository.newObjectReader()); }
Example 5
Source File: StashApplyCommand.java From orion.server with Eclipse Public License 1.0 | 5 votes |
private void checkoutPath(DirCacheEntry entry, ObjectReader reader) { try { DirCacheCheckout.checkoutEntry(repo, entry, reader); } catch (IOException e) { throw new JGitInternalException(MessageFormat.format(JGitText.get().checkoutConflictWithFile, entry.getPathString()), e); } }