summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src
diff options
context:
space:
mode:
authorThomas Wolf <thomas.wolf@paranor.ch>2020-12-30 10:12:34 +0100
committerThomas Wolf <thomas.wolf@paranor.ch>2020-12-30 10:51:14 +0100
commit5b1a6e0e382da62e8678afdb2524109efb38eeb4 (patch)
tree838914dd3a6355044bc6b02382bbe8534755d9ac /org.eclipse.jgit/src
parent086f474054440579dece78aa3a12a3157c80b344 (diff)
downloadjgit-5b1a6e0e382da62e8678afdb2524109efb38eeb4.tar.gz
jgit-5b1a6e0e382da62e8678afdb2524109efb38eeb4.zip
Fix NPE in DirCacheCheckout
If a file exists in head, merge, and the working tree, but not in the index, and we're doing a force checkout, the checkout must be an "update", not a "keep". This is a follow-up on If3a9b9e60064459d187c7db04eb4471a72c6cece. Bug: 569962 Change-Id: I59a7ac41898ddc1dd90e86b09b621a41fdf45667 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Diffstat (limited to 'org.eclipse.jgit/src')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java18
1 files changed, 10 insertions, 8 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java
index 344626de37..671475ed47 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java
@@ -946,12 +946,14 @@ public class DirCacheCheckout {
// called before). Ignore the cached deletion and use what we
// find in Merge. Potentially updates the file.
if (equalIdAndMode(hId, hMode, mId, mMode)) {
- if (initialCheckout)
+ if (initialCheckout || force) {
update(name, mId, mMode);
- else
+ } else {
keep(name, dce, f);
- } else
+ }
+ } else {
conflict(name, dce, h, m);
+ }
}
} else {
// Something in Index
@@ -1214,10 +1216,13 @@ public class DirCacheCheckout {
private void keep(String path, DirCacheEntry e, WorkingTreeIterator f)
throws IOException {
- if (e != null && !FileMode.TREE.equals(e.getFileMode())) {
+ if (e == null) {
+ return;
+ }
+ if (!FileMode.TREE.equals(e.getFileMode())) {
builder.add(e);
}
- if (e != null && force) {
+ if (force) {
if (f == null || f.isModified(e, true, walk.getObjectReader())) {
kept.add(path);
checkoutEntry(repo, e, walk.getObjectReader(), false,
@@ -1448,9 +1453,6 @@ public class DirCacheCheckout {
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());