]> source.dussan.org Git - jgit.git/commitdiff
Add new submodule layout to SubmoduleAddCommand 34/49734/2
authorChristian Halstrick <christian.halstrick@sap.com>
Tue, 9 Jun 2015 07:31:26 +0000 (09:31 +0200)
committerMatthias Sohn <matthias.sohn@sap.com>
Wed, 10 Jun 2015 22:11:27 +0000 (00:11 +0200)
The new submodule layout where GITDIR of a submodule is located at
<parent-repo-GITDIR>/modules/<submodule-path> was only used during
clone. Teach SubmoduleAddCommand to use the new layout.

Bug: 469666
Change-Id: Ie97dc0607b71499560444616f362bccee9cce515
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CloneCommandTest.java
org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleAddCommand.java

index 3b2fa6c37dfe29b1b28e77be7758d47925683120..72cc51be98e3335cab7b76ace0887667ea5e7a4f 100644 (file)
@@ -391,6 +391,17 @@ public class CloneCommandTest extends RepositoryTestCase {
                git.add().addFilepattern(path)
                                .addFilepattern(Constants.DOT_GIT_MODULES).call();
                git.commit().setMessage("adding submodule").call();
+               try (SubmoduleWalk walk = SubmoduleWalk.forIndex(git.getRepository())) {
+                       assertTrue(walk.next());
+                       Repository subRepo = walk.getRepository();
+                       addRepoToClose(subRepo);
+                       assertNotNull(subRepo);
+                       assertEquals(
+                                       new File(git.getRepository().getWorkTree(), walk.getPath()),
+                                       subRepo.getWorkTree());
+                       assertEquals(new File(new File(git.getRepository().getDirectory(),
+                                       "modules"), walk.getPath()), subRepo.getDirectory());
+               }
 
                File directory = createTempDirectory("testCloneRepositoryWithSubmodules");
                CloneCommand clone = Git.cloneRepository();
index 06c8f414e345b33eff9a43ba18baf1c3fcca0ecf..fbb24c1577a105b4645cafb2f11ad0c7c9f9f04c 100644 (file)
@@ -173,6 +173,8 @@ public class SubmoduleAddCommand extends
                CloneCommand clone = Git.cloneRepository();
                configure(clone);
                clone.setDirectory(moduleDirectory);
+               clone.setGitDir(new File(new File(repo.getDirectory(),
+                               Constants.MODULES), path));
                clone.setURI(resolvedUri);
                if (monitor != null)
                        clone.setProgressMonitor(monitor);