Improvement #2051
Updated by Henning Blohm about 5 years ago
h2. Acceptance Criteria
* Only the needed branch should be cloned
* Preferrably only a shallow clone should be created
* Alternatively, we could switch to per-component checkout from the repo.
h2. Implementation Hint
* See https://bugs.eclipse.org/bugs/show_bug.cgi?id=466858 for a starting point
For example, the following code should (but seemingly does not yet) only clone a single branch:
<pre>
<code>
package com.zfabrik.gitcr.test;
import java.io.File;
import java.util.Arrays;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.ListBranchCommand.ListMode;
import org.eclipse.jgit.lib.ProgressMonitor;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider;
public class TestCheckout {
/**
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=466858
*/
public static void main(String[] args) throws Exception {
Git r = Git.cloneRepository()
.setCredentialsProvider(new UsernamePasswordCredentialsProvider("..",".."))
.setDirectory(new File("somewhere"))
.setURI("https://somehost/repo")
.setCloneAllBranches(false)
.setBranchesToClone(Arrays.asList("refs/heads/master"))
.call();
}
}
</code>
</pre>