diff options
author | Tudor Matrescu <mit.tudor@gmail.com> | 2020-10-21 12:41:40 +0300 |
---|---|---|
committer | Tudor Matrescu <mit.tudor@gmail.com> | 2020-12-03 02:59:10 -0500 |
commit | aa3a1ecd133628c4d9d211d2b227f96b5c3d9d8f (patch) | |
tree | f8fc30f5dc06cf6fc300bb43a45f85ea891eb838 /org.eclipse.jgit.test | |
parent | 9034c7d42349dc995c6215dfb55dcafb65d9e951 (diff) | |
download | jgit-aa3a1ecd133628c4d9d211d2b227f96b5c3d9d8f.tar.gz jgit-aa3a1ecd133628c4d9d211d2b227f96b5c3d9d8f.zip |
Added check for null on DirCacheEntry in checkoutEntry method
Observed the error when trying to force checkout from a branch
that had no changes on it. When the 'keep()' method from 'DirCacheCheckout'
method was called the 'DirCacheEntry e' was null and was passed like
this to the 'checkoutEntry()' method where the 'getObjectId()' is
being called on the 'e' object
Change-Id: If3a9b9e60064459d187c7db04eb4471a72c6cece
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/DirCacheCheckoutTest.java | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/DirCacheCheckoutTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/DirCacheCheckoutTest.java index b943486b1b..9dfceae345 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/DirCacheCheckoutTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/DirCacheCheckoutTest.java @@ -13,6 +13,7 @@ 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; @@ -47,6 +48,7 @@ import org.eclipse.jgit.errors.CorruptObjectException; 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; @@ -2146,4 +2148,11 @@ public class DirCacheCheckoutTest extends RepositoryTestCase { 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)); + } + + } |