Bug 559796 - CloneCommand semantics has changed in JGit 5.6
Summary: CloneCommand semantics has changed in JGit 5.6
Status: RESOLVED FIXED
Alias: None
Product: JGit
Classification: Technology
Component: JGit (show other bugs)
Version: 5.6   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: 5.6.1   Edit
Assignee: Thomas Wolf CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 559912 560051 (view as bug list)
Depends on:
Blocks:
 
Reported: 2020-02-03 14:56 EST by Thomas Wolf CLA
Modified: 2020-02-12 11:20 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wolf CLA 2020-02-03 14:56:54 EST
Before https://git.eclipse.org/r/#/c/151352/ , setCloneAllBranches() and setBranchesToClone() could be used independently and the settings active on call() would determine what would be done. So

  cloneCommand.setCloneAllBranches(true);
  cloneCommand.setBranchesToClone(/* some list of refs */);

would clone all branches. So would

  cloneCommand.setBranchesToClone(/* some list of refs */);
  cloneCommand.setCloneAllBranches(true);

.

Since https://git.eclipse.org/r/#/c/151352/ , the last one called wins, so only the second sequence will give a wildcard fetch refspec.

This is not just a theoretical problem. EGit uses the first sequence and expects it to clone all branches and give a fetch spec +refs/heads/*:refs/remotes/origin/*, but since that commit, it gets a series of fetch specs without wildcards and thus won't pick up new upstream branches. See org.eclipse.egit.core.op.CloneOperation.

Now I'll grant that what EGit is doing there (and in the branch selection dialog in the clone wizard) is a bit shady; the dialog should have a "Clone all branches" checkbox and EGit perhaps shouldn't set both.

But since EGit might not be the only client affected, I think it's better to restore the old behavior: all of setCloneAllBranches(), setMirror(), and setBranchesToClone() can be set or reset independently, and what to do is determined only when call() is executed: mirror > cloneAll > specific branches, if none are set, use cloneAll = true.

Also note that the javadoc of setCloneAllBranches() promises it wouldn't have an effect if setCloneAllBranches(true) had been called...

Moreover, the current implementation also allows

  cloneCommand.setMirror(true);
  cloneCommand.setBare(false);

resulting in a non-bare mirror repo.
Comment 1 Thomas Wolf CLA 2020-02-03 14:59:01 EST
(In reply to Thomas Wolf from comment #0)
> Also note that the javadoc of setCloneAllBranches() promises it wouldn't
> have an effect if setCloneAllBranches(true) had been called...

Of course I meant the javadoc of setBranchesToClone() promises it wouldn't have an effect if setCloneAllBranches(true) had been called.
Comment 2 Eclipse Genie CLA 2020-02-03 15:03:14 EST
New Gerrit change created: https://git.eclipse.org/r/157084
Comment 3 Eclipse Genie CLA 2020-02-06 19:34:21 EST
Gerrit change https://git.eclipse.org/r/157084 was merged to [stable-5.6].
Commit: http://git.eclipse.org/c/jgit/jgit.git/commit/?id=75a80c5d3c790260a35ccf21ee54329f5d160879
Comment 4 Matthias Sohn CLA 2020-02-07 04:49:16 EST
*** Bug 559912 has been marked as a duplicate of this bug. ***
Comment 5 Thomas Wolf CLA 2020-02-12 11:20:04 EST
*** Bug 560051 has been marked as a duplicate of this bug. ***