[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jgit-dev] ColneCommand won't clone all branches

My bad :(

All branches are cloned properly. I'm not describing the problem(or
the effects) correctly.

However it appears that the effect of doing a git clone --bare is not
the same as CloneComand:

Here's how I reproduce it:

When cloned using jgit api:
Git repo = Git.cloneRepository().setURI("http://github.com/chalstrick/mergeExample.git";)
		.setDirectory(new File("/tmp/mergeExample.git"))
		.setBare(true)
		.setCloneAllBranches(true)
		.call();

$ cd /tmp/mergeExample.git
$ git branch
* master
$ jgit --git-dir . branch
* master

When cloned using c-git(version 1.7.5.1)
$ git clone http://github.com/chalstrick/mergeExample.git /tmp/mergeExample2.git
$ cd /tmp/mergeExample2.git
$ git branch
* master
  side
$ jgit --git-dir . branch
* master
  side

Note that git-branch and jgit-branch in this case lists out all
tracking branches, which is different when cloned using jgit.

-- Ketan
studios.thoughtworks.com | twitter.com/ketanpkr




On Mon, May 23, 2011 at 12:18 PM, Christian Halstrick
<christian.halstrick@xxxxxxxxx> wrote:
> Hi,
>
> On Sun, May 22, 2011 at 14:04, Ketan Padegaonkar
> <ketanpadegaonkar@xxxxxxxxx> wrote:
>>
>> I can confirm that this does not work on master. There are no usages of
>> CloneCommand#setCloneAllBranches and that the method is practically a no-op
>> and the javadoc is lying :)
>
> I was trying to reproduce but for me it works. In the current version
> it is definitly not true that setCloneAllBranches() is a noop. If you
> call it with "true" we'll add the refspec
> "+refs/heads/*:refs/remotes/origin/*" before we fetch. So, maybe you
> have an old version. I also checked with this code snippet:
>
>    File tmpDir = new File(System.getProperty("java.io.tmpdir"), "tmp"
> + System.currentTimeMillis());
>    Git repo1 = Git.cloneRepository()
>            .setURI("http://github.com/chalstrick/mergeExample.git";)
>            .setDirectory(new File(tmpDir, "repo1")).call();
>    for (Ref b : repo1.branchList().setListMode(ListMode.ALL).call())
>      System.out.println("(standard): cloned branch " + b.getName());
>    Git repo2 = Git.cloneRepository()
>            .setURI("http://github.com/chalstrick/mergeExample.git";)
>            .setDirectory(new File(tmpDir, "repo2"))
>            .setCloneAllBranches(true).call();
>    for (Ref b : repo2.branchList().setListMode(ListMode.ALL).call())
>      System.out.println("(cloneAllBranches): cloned branch " + b.getName());
>    Git repo3 = Git.cloneRepository()
>            .setURI("http://github.com/chalstrick/mergeExample.git";)
>            .setDirectory(new File(tmpDir, "repo3"))
>            .setBranchesToClone(Arrays.asList("refs/heads/master")).call();
>    for (Ref b : repo3.branchList().setListMode(ListMode.ALL).call())
>      System.out.println("(cloneSingleBranch): cloned branch " + b.getName());
>
> That returns for me the expected:
>
> (standard): cloned branch refs/heads/master
> (standard): cloned branch refs/remotes/origin/master
> (standard): cloned branch refs/remotes/origin/side
> (cloneAllBranches): cloned branch refs/heads/master
> (cloneAllBranches): cloned branch refs/remotes/origin/master
> (cloneAllBranches): cloned branch refs/remotes/origin/side
> (cloneSingleBranch): cloned branch refs/heads/master
> (cloneSingleBranch): cloned branch refs/remotes/origin/master
>
> Ciao
>  Chris
>