The latest changes to IndexDiff just assumed that all configured submodules are allways cloned. If a configured submodule did not exist an exception was thrown. This is fixed by this commit. Bug: 450567 Change-Id: Iabe3b196d998c19483082e5720038ebddaeb1890tags/v3.6.0.201411121045-m1
import java.io.FileWriter; | import java.io.FileWriter; | ||||
import java.io.IOException; | import java.io.IOException; | ||||
import org.eclipse.jgit.api.Git; | |||||
import org.eclipse.jgit.api.Status; | |||||
import org.eclipse.jgit.api.errors.GitAPIException; | |||||
import org.eclipse.jgit.dircache.DirCache; | import org.eclipse.jgit.dircache.DirCache; | ||||
import org.eclipse.jgit.dircache.DirCacheEditor; | import org.eclipse.jgit.dircache.DirCacheEditor; | ||||
import org.eclipse.jgit.dircache.DirCacheEditor.PathEdit; | import org.eclipse.jgit.dircache.DirCacheEditor.PathEdit; | ||||
import org.eclipse.jgit.dircache.DirCacheEntry; | import org.eclipse.jgit.dircache.DirCacheEntry; | ||||
import org.eclipse.jgit.errors.ConfigInvalidException; | import org.eclipse.jgit.errors.ConfigInvalidException; | ||||
import org.eclipse.jgit.errors.NoWorkTreeException; | |||||
import org.eclipse.jgit.junit.RepositoryTestCase; | import org.eclipse.jgit.junit.RepositoryTestCase; | ||||
import org.eclipse.jgit.junit.TestRepository; | import org.eclipse.jgit.junit.TestRepository; | ||||
import org.eclipse.jgit.lib.Config; | import org.eclipse.jgit.lib.Config; | ||||
@Test | @Test | ||||
public void repositoryWithRootLevelSubmodule() throws IOException, | public void repositoryWithRootLevelSubmodule() throws IOException, | ||||
ConfigInvalidException { | |||||
ConfigInvalidException, NoWorkTreeException, GitAPIException { | |||||
final ObjectId id = ObjectId | final ObjectId id = ObjectId | ||||
.fromString("abcd1234abcd1234abcd1234abcd1234abcd1234"); | .fromString("abcd1234abcd1234abcd1234abcd1234abcd1234"); | ||||
final String path = "sub"; | final String path = "sub"; | ||||
assertNull(gen.getModulesUpdate()); | assertNull(gen.getModulesUpdate()); | ||||
assertNull(gen.getModulesUrl()); | assertNull(gen.getModulesUrl()); | ||||
assertNull(gen.getRepository()); | assertNull(gen.getRepository()); | ||||
Status status = Git.wrap(db).status().call(); | |||||
assertTrue(!status.isClean()); | |||||
assertFalse(gen.next()); | assertFalse(gen.next()); | ||||
} | } | ||||
throw e1; | throw e1; | ||||
} | } | ||||
Repository subRepo = smw.getRepository(); | Repository subRepo = smw.getRepository(); | ||||
ObjectId subHead = subRepo.resolve("HEAD"); //$NON-NLS-1$ | |||||
if (subHead != null && !subHead.equals(smw.getObjectId())) | |||||
modified.add(smw.getPath()); | |||||
else if (ignoreSubmoduleMode != IgnoreSubmoduleMode.DIRTY) { | |||||
IndexDiff smid = submoduleIndexDiffs.get(smw.getPath()); | |||||
if (smid == null) { | |||||
smid = new IndexDiff(subRepo, smw.getObjectId(), | |||||
wTreeIt.getWorkingTreeIterator(subRepo)); | |||||
submoduleIndexDiffs.put(smw.getPath(), smid); | |||||
} | |||||
if (smid.diff()) { | |||||
if (ignoreSubmoduleMode == IgnoreSubmoduleMode.UNTRACKED | |||||
&& smid.getAdded().isEmpty() | |||||
&& smid.getChanged().isEmpty() | |||||
&& smid.getConflicting().isEmpty() | |||||
&& smid.getMissing().isEmpty() | |||||
&& smid.getModified().isEmpty() | |||||
&& smid.getRemoved().isEmpty()) { | |||||
continue; | |||||
} | |||||
if (subRepo != null) { | |||||
ObjectId subHead = subRepo.resolve("HEAD"); //$NON-NLS-1$ | |||||
if (subHead != null && !subHead.equals(smw.getObjectId())) | |||||
modified.add(smw.getPath()); | modified.add(smw.getPath()); | ||||
else if (ignoreSubmoduleMode != IgnoreSubmoduleMode.DIRTY) { | |||||
IndexDiff smid = submoduleIndexDiffs.get(smw.getPath()); | |||||
if (smid == null) { | |||||
smid = new IndexDiff(subRepo, smw.getObjectId(), | |||||
wTreeIt.getWorkingTreeIterator(subRepo)); | |||||
submoduleIndexDiffs.put(smw.getPath(), smid); | |||||
} | |||||
if (smid.diff()) { | |||||
if (ignoreSubmoduleMode == IgnoreSubmoduleMode.UNTRACKED | |||||
&& smid.getAdded().isEmpty() | |||||
&& smid.getChanged().isEmpty() | |||||
&& smid.getConflicting().isEmpty() | |||||
&& smid.getMissing().isEmpty() | |||||
&& smid.getModified().isEmpty() | |||||
&& smid.getRemoved().isEmpty()) { | |||||
continue; | |||||
} | |||||
modified.add(smw.getPath()); | |||||
} | |||||
} | } | ||||
} | } | ||||
} | } |