package org.eclipse.jgit.lib;
import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.eclipse.jgit.dircache.DirCacheCheckout.checkoutEntry;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import org.eclipse.jgit.errors.NoWorkTreeException;
import org.eclipse.jgit.events.ChangeRecorder;
import org.eclipse.jgit.events.ListenerHandle;
+import org.eclipse.jgit.internal.storage.dfs.InMemoryRepository;
import org.eclipse.jgit.junit.RepositoryTestCase;
import org.eclipse.jgit.junit.TestRepository;
import org.eclipse.jgit.junit.TestRepository.BranchBuilder;
assertEquals("WorkDir has not the right size.", i.size(), nrFiles);
}
}
+
+ @Test
+ public void shouldReturnAndNotThrowNPEWhenCheckoutEntryIsCalledWithNullEntry() throws Exception{
+ checkoutEntry(new InMemoryRepository(null), null, null, true, new CheckoutMetadata(null, null));
+ }
+
+
}
private void keep(String path, DirCacheEntry e, WorkingTreeIterator f)
throws IOException {
- if (e != null && !FileMode.TREE.equals(e.getFileMode()))
+ if (e != null && !FileMode.TREE.equals(e.getFileMode())) {
builder.add(e);
- if (force) {
+ }
+ if (e != null && force) {
if (f == null || f.isModified(e, true, walk.getObjectReader())) {
kept.add(path);
checkoutEntry(repo, e, walk.getObjectReader(), false,
public static void checkoutEntry(Repository repo, DirCacheEntry entry,
ObjectReader or, boolean deleteRecursive,
CheckoutMetadata checkoutMetadata) throws IOException {
+ if (entry == null) {
+ return;
+ }
if (checkoutMetadata == null)
checkoutMetadata = CheckoutMetadata.EMPTY;
ObjectLoader ol = or.open(entry.getObjectId());