Browse Source

Remove null access warning in DirCacheCheckout

Initially fill in the current DirCacheEntry field guarding 
against a null index tree and use that variable instead of
calling getDirCacheEntry() on a possibly null DirCacheBuildIterator.

Change-Id: I16f388a16636aefdb07d66dae5d05655009e2a0e
stable-2.0
Kevin Sawicki 13 years ago
parent
commit
d364fb2d4f
  1. 26
      org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java

26
org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java vendored

@ -508,7 +508,7 @@ public class DirCacheCheckout {
void processEntry(AbstractTreeIterator h, AbstractTreeIterator m, void processEntry(AbstractTreeIterator h, AbstractTreeIterator m,
DirCacheBuildIterator i, WorkingTreeIterator f) throws IOException { DirCacheBuildIterator i, WorkingTreeIterator f) throws IOException {
DirCacheEntry dce; DirCacheEntry dce = i != null ? i.getDirCacheEntry() : null;
String name = walk.getPathString(); String name = walk.getPathString();
@ -595,7 +595,7 @@ public class DirCacheCheckout {
switch (ffMask) { switch (ffMask) {
case 0xDDF: // 1 2 case 0xDDF: // 1 2
if (isModified(name)) { if (isModified(name)) {
conflict(name, i.getDirCacheEntry(), h, m); // 1 conflict(name, dce, h, m); // 1
} else { } else {
update(name, mId, mMode); // 2 update(name, mId, mMode); // 2
} }
@ -625,41 +625,40 @@ public class DirCacheCheckout {
break; break;
case 0xDF0: // conflict without a rule case 0xDF0: // conflict without a rule
case 0x0FD: // 15 case 0x0FD: // 15
conflict(name, (i != null) ? i.getDirCacheEntry() : null, h, m); conflict(name, dce, h, m);
break; break;
case 0xFDF: // 7 8 9 case 0xFDF: // 7 8 9
if (equalIdAndMode(hId, hMode, mId, mMode)) { if (equalIdAndMode(hId, hMode, mId, mMode)) {
if (isModified(name)) if (isModified(name))
conflict(name, i.getDirCacheEntry(), h, m); // 8 conflict(name, dce, h, m); // 8
else else
update(name, mId, mMode); // 7 update(name, mId, mMode); // 7
} else if (!isModified(name)) } else if (!isModified(name))
update(name, mId, mMode); // 9 update(name, mId, mMode); // 9
else else
// To be confirmed - this case is not in the table. // To be confirmed - this case is not in the table.
conflict(name, i.getDirCacheEntry(), h, m); conflict(name, dce, h, m);
break; break;
case 0xFD0: // keep without a rule case 0xFD0: // keep without a rule
keep(i.getDirCacheEntry()); keep(dce);
break; break;
case 0xFFD: // 12 13 14 case 0xFFD: // 12 13 14
if (equalIdAndMode(hId, hMode, iId, iMode)) { if (equalIdAndMode(hId, hMode, iId, iMode))
dce = i.getDirCacheEntry();
if (f == null || f.isModified(dce, true)) if (f == null || f.isModified(dce, true))
conflict(name, dce, h, m); conflict(name, dce, h, m);
else else
remove(name); remove(name);
} else else
conflict(name, i.getDirCacheEntry(), h, m); conflict(name, dce, h, m);
break; break;
case 0x0DF: // 16 17 case 0x0DF: // 16 17
if (!isModified(name)) if (!isModified(name))
update(name, mId, mMode); update(name, mId, mMode);
else else
conflict(name, i.getDirCacheEntry(), h, m); conflict(name, dce, h, m);
break; break;
default: default:
keep(i.getDirCacheEntry()); keep(dce);
} }
return; return;
} }
@ -707,7 +706,6 @@ public class DirCacheCheckout {
else else
update(name, mId, mMode); // 3 update(name, mId, mMode); // 3
} else { } else {
dce = i.getDirCacheEntry();
if (h == null) { if (h == null) {
/** /**
* <pre> * <pre>
@ -747,7 +745,7 @@ public class DirCacheCheckout {
* </pre> * </pre>
*/ */
if (dce.getFileMode() == FileMode.GITLINK) { if (iMode == FileMode.GITLINK) {
// Submodules that disappear from the checkout must // Submodules that disappear from the checkout must
// be removed from the index, but not deleted from disk. // be removed from the index, but not deleted from disk.
remove(name); remove(name);

Loading…
Cancel
Save