Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 351314

Summary: JGit PushCommand implicitly creates branches on the remote system
Product: [Technology] JGit Reporter: Christian Halstrick <christian.halstrick>
Component: JGitAssignee: Project Inbox <jgit.core-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: achilles.sabine, christian.campo, daniel_megert, germhaine, pwebster, remy.suen, rolf.theunissen, stefan.lay, tjwatson, twolf
Version: unspecified   
Target Milestone: 6.1   
Hardware: PC   
OS: All   
See Also: https://git.eclipse.org/r/136629
https://git.eclipse.org/r/c/jgit/jgit/+/136629
https://git.eclipse.org/r/c/jgit/jgit/+/190662
https://git.eclipse.org/c/jgit/jgit.git/commit/?id=2883762219e37dc88d7592b4b8f7d5b115baac04
https://git.eclipse.org/c/jgit/jgit.git/commit/?id=504001228ba6a43179a72e56ce03aa217c2bdea4
Whiteboard:
Bug Depends on:    
Bug Blocks: 431872    

Description Christian Halstrick CLA 2011-07-06 07:55:56 EDT
When you use JGit PushCommand and you don't specify an explicit refspec then JGit uses implicitly a refspec which potentially leads to the creation of a new branch in the remote system. The new branch will have the same name as the currently checked out branch.

Here JGit behaves differently from native git, where a push without an explicit refspec leads to the update of all "matching" branches (branches which exists locally and remotely). A native git push would not create new branches.

My problem is that JGit under the hood (without an explicit refespec) takes my local branch names to create branches on the remote system. Up to know I was sure that I can name my branches as I like (tmp1, tmp2, f***ingBugFix, ...) because I knew that J/EGit will never publish these names without my explicit order. That's not true anymore.

My proposal: If we can't have these "update only matching branches" rule then we should simply not update/create any branches if user "forgot" to specify any refspec.
Comment 1 Christian Campo CLA 2011-08-02 07:42:47 EDT
It seems that Egit asks actually for the passphrase when I do synchronize workspace. Just the clone wouldn't…. (if that makes any sense)
Comment 2 Christian Campo CLA 2011-08-02 07:43:06 EDT
(In reply to comment #1)
> It seems that Egit asks actually for the passphrase when I do synchronize
> workspace. Just the clone wouldn't…. (if that makes any sense)

sorry wrong bug…..
Comment 3 Rolf Theunissen CLA 2019-02-10 07:28:21 EST
JGit currently does not support the "push.default" configuration option. CGit defaults to "simple" behavior. The default behavior of JGit is "current", which explains the creation of the new branches.

Note that "simple" behaves as "current" for triangular workflows. In non-triangular workflows, it adds the safety check to not create new branches.
Comment 4 Eclipse Genie CLA 2019-02-10 13:00:26 EST
New Gerrit change created: https://git.eclipse.org/r/136629
Comment 5 Eclipse Genie CLA 2022-02-10 05:38:38 EST
New Gerrit change created: https://git.eclipse.org/r/c/jgit/jgit/+/190662
Comment 8 Thomas Wolf CLA 2022-02-18 14:20:42 EST
*** Bug 445491 has been marked as a duplicate of this bug. ***