gitmodules.setString(CONFIG_SUBMODULE_SECTION, path, CONFIG_KEY_URL,
"git://example.com/sub");
writeTrashFile(DOT_GIT_MODULES, gitmodules.toText());
DirCache cache = db.lockDirCache();
DirCacheEditor editor = cache.editor();
editor.add(new PathEdit(path) {
public void apply(DirCacheEntry ent) {
ent.setFileMode(FileMode.GITLINK);
ent.setObjectId(subId);
}
});
editor.add(new PathEdit(DOT_GIT_MODULES) {
public void apply(DirCacheEntry ent) {
ent.setFileMode(FileMode.REGULAR_FILE);
ent.setObjectId(gitmodulesBlob);
}
});
editor.commit();
SubmoduleWalk gen = SubmoduleWalk.forIndex(db);
assertTrue(gen.next());
assertEquals(path, gen.getPath());
assertEquals(subId, gen.getObjectId());