IndexDiffFilter should never filter entries with stage!=0

If the IndexDiffFilter is asked whether it should include or filter out
a certain path and for that path there is a dircache entry with a stage
different from 0, then the filter should never filter out this entry.
IndexDiffFilter is an optimized version of AnyDiffFilter and there is no
case where the index contains non-0 stages but we still don't see any
diff for that path.

Change-Id: I25915880f304090fe90584c79bddf021231227a2
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
Christian Halstrick 2014-08-01 11:28:01 +02:00 committed by Matthias Sohn
parent fd07ee54ef
commit ddbf67e058
2 changed files with 30 additions and 1 deletions

View File

@ -134,6 +134,31 @@ public void testFileCommitted() throws Exception {
assertFalse(treeWalk.next());
}
@Test
public void testConflicts() throws Exception {
RevCommit initial = git.commit().setMessage("initial").call();
writeTrashFile(FILE, "master");
git.add().addFilepattern(FILE).call();
RevCommit master = git.commit().setMessage("master").call();
git.checkout().setName("refs/heads/side")
.setCreateBranch(true).setStartPoint(initial).call();
writeTrashFile(FILE, "side");
git.add().addFilepattern(FILE).call();
RevCommit side = git.commit().setMessage("side").call();
assertFalse(git.merge().include("master", master).call()
.getMergeStatus()
.isSuccessful());
assertEquals(read(FILE),
"<<<<<<< HEAD\nside\n=======\nmaster\n>>>>>>> master\n");
writeTrashFile(FILE, "master");
TreeWalk treeWalk = createTreeWalk(side);
int count = 0;
while (treeWalk.next())
count++;
assertEquals(2, count);
}
@Test
public void testFileInFolderCommitted() throws Exception {
RevCommit commit = writeFileInFolderAndCommit();

View File

@ -139,9 +139,13 @@ public boolean include(TreeWalk tw) throws MissingObjectException,
DirCacheIterator di = tw.getTree(dirCache, DirCacheIterator.class);
if (di != null) {
DirCacheEntry dce = di.getDirCacheEntry();
if (dce != null)
if (dce != null) {
if (dce.isAssumeValid())
return false;
// Never filter index entries with a stage different from 0
if (dce.getStage() != 0)
return true;
}
}
if (!tw.isPostOrderTraversal()) {