Browse Source

Merge "Refactor and comment complicated if statements"

stable-0.11
Chris Aniszczyk 14 years ago committed by Code Review
parent
commit
509662653b
  1. 41
      org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java

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

@ -304,31 +304,58 @@ public class DirCacheCheckout {
void processEntry(CanonicalTreeParser m, DirCacheBuildIterator i, void processEntry(CanonicalTreeParser m, DirCacheBuildIterator i,
WorkingTreeIterator f) { WorkingTreeIterator f) {
if (m != null) { if (m != null) {
if (i == null || f == null || !m.idEqual(i) // There is an entry in the merge commit. Means: we want to update
|| (i.getDirCacheEntry() != null && (f.isModified( // what's currently in the index and working-tree to that one
i.getDirCacheEntry(), true) || if (i == null) {
i.getDirCacheEntry().getStage() != 0))) { // The index entry is missing
update(m.getEntryPathString(), m.getEntryObjectId(),
m.getEntryFileMode());
} else if (f == null || !m.idEqual(i)) {
// The working tree file is missing or the merge content differs
// from index content
update(m.getEntryPathString(), m.getEntryObjectId(),
m.getEntryFileMode());
} else if (i.getDirCacheEntry() != null) {
// The index contains a file (and not a folder)
if (f.isModified(i.getDirCacheEntry(), true)
|| i.getDirCacheEntry().getStage() != 0)
// The working tree file is dirty or the index contains a
// conflict
update(m.getEntryPathString(), m.getEntryObjectId(), update(m.getEntryPathString(), m.getEntryObjectId(),
m.getEntryFileMode()); m.getEntryFileMode());
else
keep(i.getDirCacheEntry());
} else } else
// The index contains a folder
keep(i.getDirCacheEntry()); keep(i.getDirCacheEntry());
} else { } else {
// There is no entry in the merge commit. Means: we want to delete
// what's currently in the index and working tree
if (f != null) { if (f != null) {
// There is a file/folder for that path in the working tree
if (walk.isDirectoryFileConflict()) { if (walk.isDirectoryFileConflict()) {
conflicts.add(walk.getPathString()); conflicts.add(walk.getPathString());
} else { } else {
// No file/folder conflict exists. All entries are files or
// all entries are folders
if (i != null) { if (i != null) {
// ... and the working dir contained a file or folder -> // ... and the working tree contained a file or folder
// add it to the removed set and remove it from // -> add it to the removed set and remove it from
// conflicts set // conflicts set
remove(i.getEntryPathString()); remove(i.getEntryPathString());
conflicts.remove(i.getEntryPathString()); conflicts.remove(i.getEntryPathString());
} }
} }
} else if (i.getDirCacheEntry().getStage() == 0) } else {
// There is no file/folder for that path in the working tree.
// The only entry we have is the index entry. If that entry is a
// conflict simply remove it. Otherwise keep that entry in the
// index
if (i.getDirCacheEntry().getStage() == 0)
keep(i.getDirCacheEntry()); keep(i.getDirCacheEntry());
} }
} }
}
/** /**
* Execute this checkout * Execute this checkout

Loading…
Cancel
Save