Merge branch 'stable-5.13' into stable-6.0

* stable-5.13:
  Revert "RefDirectory.scanRef: Re-use file existence check done in snapshot creation"
  TreeRevFilter: fix wrong stop when the given path disappears

Change-Id: Ibd69e9d941ad9262b61dd0c4368e48cb82597a12
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
This commit is contained in:
Thomas Wolf 2021-12-26 16:03:40 +01:00
commit 7146bde45f
4 changed files with 24 additions and 14 deletions

View File

@ -15,6 +15,7 @@
import java.util.Collections;
import org.eclipse.jgit.dircache.DirCacheEntry;
import org.eclipse.jgit.treewalk.filter.AndTreeFilter;
import org.eclipse.jgit.treewalk.filter.PathFilterGroup;
import org.eclipse.jgit.treewalk.filter.TreeFilter;
@ -253,4 +254,23 @@ public void testStringOfPearls_FilePath3_NoParentRewriting()
assertEquals(0, a.getParentCount());
assertNull(rw.next());
}
@Test
public void testStopWhenPathDisappears() throws Exception {
DirCacheEntry file1 = file("src/d1/file1", blob("a"));
DirCacheEntry file2 = file("src/d1/file2", blob("a"));
DirCacheEntry file3 = file("src/d1/file3", blob("a"));
RevCommit a = commit(tree(file1));
RevCommit b = commit(tree(file1, file2), a);
RevCommit c = commit(tree(file1, file3), a);
RevCommit d = commit(tree(file1, file2, file3), b, c);
filter("src/d1");
markStart(d);
rw.setRewriteParents(false);
assertCommit(d, rw.next());
assertCommit(c, rw.next());
assertCommit(b, rw.next());
assertCommit(a, rw.next());
}
}

View File

@ -420,15 +420,6 @@ public boolean equals(Object obj) {
return equals(other);
}
/**
* Check if the file exists
*
* @return true if the file exists
*/
public boolean fileExists() {
return !MISSING_FILEKEY.equals(this.fileKey);
}
/** {@inheritDoc} */
@Override
public int hashCode() {

View File

@ -1092,10 +1092,6 @@ LooseRef scanRef(LooseRef ref, String name) throws IOException {
final int limit = 4096;
final byte[] buf;
FileSnapshot otherSnapshot = FileSnapshot.save(path);
if (!otherSnapshot.fileExists()) {
return null;
}
try {
buf = IO.readSome(path, limit);
} catch (FileNotFoundException noFile) {

View File

@ -211,7 +211,10 @@ public boolean include(RevWalk walker, RevCommit c)
// "empty tree root" and thus their history is not relevant.
// Cut our grandparents to be an empty list.
//
pList[i].parents = RevCommit.NO_PARENTS;
tw.reset(pList[i].getTree());
if (!tw.next()) {
pList[i].parents = RevCommit.NO_PARENTS;
}
}
// We have an interesting difference relative to this parent.