diff options
author | Yuxuan 'fishy' Wang <fishywang@google.com> | 2014-07-29 15:43:04 -0700 |
---|---|---|
committer | Yuxuan 'fishy' Wang <fishywang@google.com> | 2014-07-29 16:16:36 -0700 |
commit | a9b9c5b324256e3e1f9c3267a81bf8bd1dbbbec4 (patch) | |
tree | 1175f49d3d4ca5dbec066396c891dad3cafe057e /org.eclipse.jgit.test | |
parent | 5171a1843aafefe071ccf5965f0c303c50508237 (diff) | |
download | jgit-a9b9c5b324256e3e1f9c3267a81bf8bd1dbbbec4.tar.gz jgit-a9b9c5b324256e3e1f9c3267a81bf8bd1dbbbec4.zip |
Remove overlapping submodules from repo manifest.
Apparently repo allows projects overlapping, e.g. one project's path is "foo"
and another project's path is "foo/bar". This is not supported in git submodule.
At JGit repo side we'll skip all the submodules that are in subdirectories of
other submodules, and on repo side we'll make them submodules to resolve this
problem.
Change-Id: I6820c4ef400c530a36150b1228706adfcc43ef64
Signed-off-by: Yuxuan 'fishy' Wang <fishywang@google.com>
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/RepoCommandTest.java | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/RepoCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/RepoCommandTest.java index 15a7ef93c4..3e5ef02738 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/RepoCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/gitrepo/RepoCommandTest.java @@ -512,6 +512,65 @@ public class RepoCommandTest extends RepositoryTestCase { assertFalse("The foo submodule shouldn't exist", foo); } + @Test + public void testRemoveOverlappingBare() throws Exception { + Repository remoteDb = createBareRepository(); + Repository tempDb = createWorkRepository(); + StringBuilder xmlContent = new StringBuilder(); + xmlContent.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n") + .append("<manifest>") + .append("<remote name=\"remote1\" fetch=\".\" />") + .append("<default revision=\"master\" remote=\"remote1\" />") + .append("<project path=\"foo/bar\" name=\"") + .append(groupBUri) + .append("\" />") + .append("<project path=\"a\" name=\"") + .append(groupAUri) + .append("\" />") + .append("<project path=\"foo\" name=\"") + .append(defaultUri) + .append("\" />") + .append("</manifest>"); + JGitTestUtil.writeTrashFile( + tempDb, "manifest.xml", xmlContent.toString()); + RepoCommand command = new RepoCommand(remoteDb); + command + .setPath(tempDb.getWorkTree().getAbsolutePath() + "/manifest.xml") + .setURI(rootUri) + .call(); + // Clone it + File directory = createTempDirectory("testRemoveOverlappingBare"); + Repository localDb = Git + .cloneRepository() + .setDirectory(directory) + .setURI(remoteDb.getDirectory().toURI().toString()) + .call() + .getRepository(); + // The .gitmodules file should have 'submodule "foo"' and shouldn't have + // 'submodule "foo/bar"' lines. + File dotmodules = new File(localDb.getWorkTree(), + Constants.DOT_GIT_MODULES); + BufferedReader reader = new BufferedReader(new FileReader(dotmodules)); + boolean foo = false; + boolean foobar = false; + boolean a = false; + while (true) { + String line = reader.readLine(); + if (line == null) + break; + if (line.contains("submodule \"foo\"")) + foo = true; + if (line.contains("submodule \"foo/bar\"")) + foobar = true; + if (line.contains("submodule \"a\"")) + a = true; + } + reader.close(); + assertTrue("The foo submodule should exist", foo); + assertFalse("The foo/bar submodule shouldn't exist", foobar); + assertTrue("The a submodule should exist", a); + } + private void resolveRelativeUris() { // Find the longest common prefix ends with "/" as rootUri. defaultUri = defaultDb.getDirectory().toURI().toString(); |