Browse Source

Reuse existing modes and ids

This change replaces calls to getEntryObjectId and getEntryFileMode
with the existing method local variables for the index, merge, and
head tree iterators.

Change-Id: I75d1edfdd192a009fc916102ec052434c6302d00
stable-2.0
Kevin Sawicki 13 years ago
parent
commit
0fb0e84405
  1. 28
      org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java

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

@ -577,13 +577,11 @@ public class DirCacheCheckout {
int ffMask = 0; int ffMask = 0;
if (h != null) if (h != null)
ffMask = FileMode.TREE.equals(h.getEntryFileMode()) ? 0xD00 : 0xF00; ffMask = FileMode.TREE.equals(hMode) ? 0xD00 : 0xF00;
if (i != null) if (i != null)
ffMask |= FileMode.TREE.equals(i.getEntryFileMode()) ? 0x0D0 ffMask |= FileMode.TREE.equals(iMode) ? 0x0D0 : 0x0F0;
: 0x0F0;
if (m != null) if (m != null)
ffMask |= FileMode.TREE.equals(m.getEntryFileMode()) ? 0x00D ffMask |= FileMode.TREE.equals(mMode) ? 0x00D : 0x00F;
: 0x00F;
// Check whether we have a possible file/folder conflict. Therefore we // Check whether we have a possible file/folder conflict. Therefore we
// need a least one file and one folder. // need a least one file and one folder.
@ -599,7 +597,7 @@ public class DirCacheCheckout {
if (isModified(name)) { if (isModified(name)) {
conflict(name, i.getDirCacheEntry(), h, m); // 1 conflict(name, i.getDirCacheEntry(), h, m); // 1
} else { } else {
update(name, m.getEntryObjectId(), m.getEntryFileMode()); // 2 update(name, mId, mMode); // 2
} }
break; break;
@ -623,7 +621,7 @@ public class DirCacheCheckout {
// are found later // are found later
break; break;
case 0xD0F: // 19 case 0xD0F: // 19
update(name, mId, m.getEntryFileMode()); update(name, mId, mMode);
break; break;
case 0xDF0: // conflict without a rule case 0xDF0: // conflict without a rule
case 0x0FD: // 15 case 0x0FD: // 15
@ -634,9 +632,9 @@ public class DirCacheCheckout {
if (isModified(name)) if (isModified(name))
conflict(name, i.getDirCacheEntry(), h, m); // 8 conflict(name, i.getDirCacheEntry(), h, m); // 8
else else
update(name, mId, m.getEntryFileMode()); // 7 update(name, mId, mMode); // 7
} else if (!isModified(name)) } else if (!isModified(name))
update(name, mId, m.getEntryFileMode()); // 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, i.getDirCacheEntry(), h, m);
@ -656,7 +654,7 @@ public class DirCacheCheckout {
break; break;
case 0x0DF: // 16 17 case 0x0DF: // 16 17
if (!isModified(name)) if (!isModified(name))
update(name, mId, m.getEntryFileMode()); update(name, mId, mMode);
else else
conflict(name, i.getDirCacheEntry(), h, m); conflict(name, i.getDirCacheEntry(), h, m);
break; break;
@ -679,7 +677,7 @@ public class DirCacheCheckout {
// make sure not to overwrite untracked files // make sure not to overwrite untracked files
if (f != null) { if (f != null) {
// A submodule is not a file. We should ignore it // A submodule is not a file. We should ignore it
if (!FileMode.GITLINK.equals(m.getEntryFileMode())) { if (!FileMode.GITLINK.equals(mMode)) {
// a dirty worktree: the index is empty but we have a // a dirty worktree: the index is empty but we have a
// workingtree-file // workingtree-file
if (mId == null if (mId == null
@ -703,11 +701,11 @@ public class DirCacheCheckout {
*/ */
if (h == null) if (h == null)
update(name, mId, m.getEntryFileMode()); // 1 update(name, mId, mMode); // 1
else if (m == null) else if (m == null)
remove(name); // 2 remove(name); // 2
else else
update(name, mId, m.getEntryFileMode()); // 3 update(name, mId, mMode); // 3
} else { } else {
dce = i.getDirCacheEntry(); dce = i.getDirCacheEntry();
if (h == null) { if (h == null) {
@ -772,12 +770,12 @@ public class DirCacheCheckout {
// For submodules just update the index with the new SHA-1 // For submodules just update the index with the new SHA-1
if (dce != null if (dce != null
&& FileMode.GITLINK.equals(dce.getFileMode())) { && FileMode.GITLINK.equals(dce.getFileMode())) {
update(name, mId, m.getEntryFileMode()); update(name, mId, mMode);
} else if (dce != null } else if (dce != null
&& (f == null || f.isModified(dce, true))) { && (f == null || f.isModified(dce, true))) {
conflict(name, dce, h, m); conflict(name, dce, h, m);
} else { } else {
update(name, mId, m.getEntryFileMode()); update(name, mId, mMode);
} }
} else { } else {
keep(dce); keep(dce);

Loading…
Cancel
Save