void processEntry(CanonicalTreeParser m, DirCacheBuildIterator i,
WorkingTreeIterator f) {
if (m != null) {
- if (i == null || f == null || !m.idEqual(i)
- || (i.getDirCacheEntry() != null && (f.isModified(
- i.getDirCacheEntry(), true) ||
- i.getDirCacheEntry().getStage() != 0))) {
+ // There is an entry in the merge commit. Means: we want to update
+ // what's currently in the index and working-tree to that one
+ if (i == null) {
+ // 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(),
+ m.getEntryFileMode());
+ else
+ keep(i.getDirCacheEntry());
} else
+ // The index contains a folder
keep(i.getDirCacheEntry());
} 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) {
+ // There is a file/folder for that path in the working tree
if (walk.isDirectoryFileConflict()) {
conflicts.add(walk.getPathString());
} else {
+ // No file/folder conflict exists. All entries are files or
+ // all entries are folders
if (i != null) {
- // ... and the working dir contained a file or folder ->
- // add it to the removed set and remove it from
+ // ... and the working tree contained a file or folder
+ // -> add it to the removed set and remove it from
// conflicts set
remove(i.getEntryPathString());
conflicts.remove(i.getEntryPathString());
}
}
- } else if (i.getDirCacheEntry().getStage() == 0)
- keep(i.getDirCacheEntry());
+ } 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());
+ }
}
}