final Config gitmodules = new Config();
gitmodules.setString(CONFIG_SUBMODULE_SECTION, path, CONFIG_KEY_PATH,
"sub");
+ // Different config in the index should be overridden by the working tree.
gitmodules.setString(CONFIG_SUBMODULE_SECTION, path, CONFIG_KEY_URL,
- "git://example.com/sub");
+ "git://example.com/bad");
final RevBlob gitmodulesBlob = testDb.blob(gitmodules.toText());
- // Different config in the working tree.
gitmodules.setString(CONFIG_SUBMODULE_SECTION, path, CONFIG_KEY_URL,
- "git://example.com/bad");
+ "git://example.com/sub");
writeTrashFile(DOT_GIT_MODULES, gitmodules.toText());
DirCache cache = db.lockDirCache();
try {
DirCache index = repository.readDirCache();
generator.setTree(new DirCacheIterator(index));
- generator.setRootTree(new DirCacheIterator(index));
- generator.useWorkingTree = true;
} catch (IOException e) {
generator.release();
throw e;
private String path;
- private boolean useWorkingTree;
-
/**
* Create submodule generator
*
* @throws ConfigInvalidException
*/
public SubmoduleWalk loadModulesConfig() throws IOException, ConfigInvalidException {
- if (rootTree != null) {
+ if (rootTree == null) {
+ File modulesFile = new File(repository.getWorkTree(),
+ Constants.DOT_GIT_MODULES);
+ FileBasedConfig config = new FileBasedConfig(modulesFile,
+ repository.getFS());
+ config.load();
+ modulesConfig = config;
+ } else {
TreeWalk configWalk = new TreeWalk(repository);
try {
configWalk.addTree(rootTree);
return this;
}
}
- if (!useWorkingTree) {
- modulesConfig = new Config();
- return this;
- }
+ modulesConfig = new Config();
} finally {
if (idx > 0)
rootTree.next(idx);
configWalk.release();
}
}
- if (repository.isBare()) {
- modulesConfig = new Config();
- } else {
- File modulesFile = new File(repository.getWorkTree(),
- Constants.DOT_GIT_MODULES);
- FileBasedConfig config = new FileBasedConfig(modulesFile,
- repository.getFS());
- config.load();
- modulesConfig = config;
- }
return this;
}