generator = new InMemorySubmoduleWalk(repository, submodulesConfig);
try {
DirCache index = repository.readDirCache();
generator.setTree(new DirCacheIterator(index));
} catch (IOException e) {
generator.release();
throw e;
}
} else {
generator = SubmoduleWalk.forIndex(repository);
}