Fix ReadTreeTests to not rely on cached index

ReadTreeTests relied on Repository.getIndex() which on
platforms which coarse FileSystemTimers failed to detect
index modifications. By explicitly reloading and writing
the index this problem is solved.

Change-Id: I0a98babfc2068a3b6b7d2257834988e1154f5b26
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
Christian Halstrick 2010-08-20 10:15:53 +02:00
parent 3820b0281a
commit 9ac29d0e91
2 changed files with 7 additions and 1 deletions

View File

@ -651,6 +651,10 @@ public void assertIndex(HashMap<String, String> i)
String expectedValue;
String path;
GitIndex theIndex=db.getIndex();
// Without an explicit refresh we might miss index updates. If the index
// is updated multiple times inside a FileSystemTimer tick db.getIndex will
// not reload the index and return a cached (stale) index.
theIndex.read();
assertEquals("Index has not the right size.", i.size(),
theIndex.getMembers().length);
for (int j = 0; j < theIndex.getMembers().length; j++) {

View File

@ -57,8 +57,10 @@ public void prescanTwoTrees(Tree head, Tree merge) throws IllegalStateException,
}
public void checkout() throws IOException {
wdc = new WorkDirCheckout(db, db.getWorkTree(), theHead, db.getIndex(), theMerge);
GitIndex index = db.getIndex();
wdc = new WorkDirCheckout(db, db.getWorkTree(), theHead, index, theMerge);
wdc.checkout();
index.write();
}
public ArrayList<String> getRemoved() {