Bug 431872 - "Push to Upstream" pushes to current branch name even when "branch.*.merge" differs
Summary: "Push to Upstream" pushes to current branch name even when "branch.*.merge" d...
Status: RESOLVED FIXED
Alias: None
Product: EGit
Classification: Technology
Component: UI (show other bugs)
Version: 3.4   Edit
Hardware: All All
: P3 normal with 4 votes (vote)
Target Milestone: 6.1   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 548915 575068 (view as bug list)
Depends on: 441938 351314 441940
Blocks:
  Show dependency tree
 
Reported: 2014-04-03 04:43 EDT by Robin Stocker CLA
Modified: 2022-02-18 13:41 EST (History)
9 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Robin Stocker CLA 2014-04-03 04:43:56 EDT
Currently in EGit, when you create a local branch that tracks a remote branch, and it does not have the same name, the result of "Push to Upstream" is surprising.

E.g. with this config:

[branch "foo"]
        remote = origin
        merge = refs/heads/bar

Running "Push to Upstream" when having "foo" checked out causes a new "foo" branch to be created on origin, instead of pushing to "bar".

C Git nowadays (with "push.default" set to "simple") asks what to do in such a case. We should also ask the following question:

The current branch "foo" has a different name than its upstream branch "bar". What do you want to do?

[Push to Upstream Branch "bar"]  [Push to "foo"]  [Start Push Branch Wizard...]

(The question should probably only come up when there is no push refspec set for the remote and there's an explicit "branch.*.merge".)
Comment 1 Andreas Krey CLA 2014-04-09 08:20:52 EDT
(In reply to Robin Stocker from comment #0)
...
> The current branch "foo" has a different name than its upstream branch
> "bar". What do you want to do?
> 
> [Push to Upstream Branch "bar"]  [Push to "foo"]  [Start Push Branch
> Wizard...]

I personally would very much appreciate when the push.default value is actually honored; either by skipping or properly defaulting this dialog.

> (The question should probably only come up when there is no push refspec set
> for the remote and there's an explicit "branch.*.merge".)

Yes and no. When I see "Commit & Push" I'd expect the current branch on which I commit to be pushed to the proper place, not a general refspec to be applied (so 'no'). On the other hand side, in that case there would be no push refspec for the remote (so 'yes').

And many thanks for the work on #430454!
Comment 2 Stephan Herrmann CLA 2014-07-27 11:17:40 EDT
I just made a back click in EGit, that's somewhat related:

I was working on a local feature branch, which is configured for push/pull against a same-named branch on origin.

When I dared to click "Commit and Push" I assumed the configuration of this branch would be used. Unfortunately the global "HEAD to origin/master" configuration was used and all my dirty WIP appeared on master <BLUSH>

I would always assume the configuration for the currently checked out branch to have precedence over any global configuration, no? Should we open a new bug for issues with "Commit and Push" from a non-master branch?

Yes I know, clicking "Commit and Push" may be a bad idea to begin with ... maybe that button should be disabled on any branch that's not based on origin/master ...
Comment 3 Robin Stocker CLA 2014-08-02 05:40:56 EDT
@Stephan: I'm not sure you're having the same bug as this one. Could you file a new bug, and attach your .git/config there?
Comment 4 Stephan Herrmann CLA 2014-08-03 08:09:40 EDT
(In reply to Robin Stocker from comment #3)
> @Stephan: I'm not sure you're having the same bug as this one. Could you
> file a new bug, and attach your .git/config there?

Done: bug 441031.
Comment 5 Robin Stocker CLA 2014-08-20 10:12:08 EDT
I think fixing bug 441938 as described in comment 6 would fix this (added dependency). Additionally, having a dropdown on the button would enable doing something else such as opening the "Push Branch..." wizard.
Comment 6 Francois Guillot CLA 2015-01-14 05:27:59 EST
Just found this bug at work today.

Everyone panicked and was thinking "oh my god I thought I understood git concepts but once again I failed",  until I found that the problem is in E/Jgit.

Since I educated my co-workers to create local branch 'bugFix_xxx' based on 'origin/master', I have to tell them to merge their work into their local 'master' branch before 'pushing to upstream' to effectively update 'origin/master'

They will hate me :)
Comment 7 Mickael Istria CLA 2015-01-14 06:07:15 EST
(In reply to Francois Guillot from comment #6)
> I have to tell them to merge their work into their local
> 'master' branch before 'pushing to upstream' to effectively update
> 'origin/master'

Or just tell them to avoid using "Push to Upstream" because it's not predictable enough for beginners ?
Comment 8 Francois Guillot CLA 2015-01-14 07:56:41 EST
(In reply to Mickael Istria from comment #7)
> (In reply to Francois Guillot from comment #6)
> > I have to tell them to merge their work into their local
> > 'master' branch before 'pushing to upstream' to effectively update
> > 'origin/master'
> 
> Or just tell them to avoid using "Push to Upstream" because it's not
> predictable enough for beginners ?

Right, I guess I deserve it.
But seriously, when you create a local branch BugXXX from origin/master, you know that the upstream of BugXXX is origin/master, so you expect 'push to upstream' to push to the master branch of the origin remote repository.
You certainly don't expect that a new branch BugXXX will be created in the origin repository (and that feeling is enforced by the fact that there is also a 'push branch BugXXX' action)
Comment 9 Rolf Theunissen CLA 2019-02-08 04:21:15 EST
Can somebody raise the importance of this bug? I think the current GIT workflow is seriously broken in Eclipse.

To reproduce:
1. Check out a remote-tracking branch as new local branch
2. Ensure that 'Configure upstream for push and pull' is selected
3. Check that the upstream for the local branch is indeed configured to be the check out branch
4. Stage a commit
5a. Select 'Commit and Push'
5b. (or) Select 'Commit' and use the 'Push to upstream' menu
6. Be amazed that the commit ended up in a new branch on the remote

What is even more surprising is that when the "Push Branch 'ABC' ..." menu is used, the configured upstream branch is selected by default.
Comment 10 Rolf Theunissen CLA 2019-02-10 07:32:24 EST
The behavior of "Push to Upstream" currently behaves as "current" for the "push.default" behavior options.

JGit only implements "current" behavior, and not the other "push.default" options.
See also, Bug 351314.
Comment 11 Thomas Wolf CLA 2022-02-10 07:52:52 EST
*** Bug 441031 has been marked as a duplicate of this bug. ***
Comment 12 Thomas Wolf CLA 2022-02-10 07:57:46 EST
(In reply to Thomas Wolf from comment #11)
> *** Bug 441031 has been marked as a duplicate of this bug. ***

Clicked the wrong button in the wrong screen. :-( 441031 is not a duplicate; it's about "Commit & Push", not about "Push to Upstream".
Comment 13 Eclipse Genie CLA 2022-02-14 09:29:50 EST
New Gerrit change created: https://git.eclipse.org/r/c/egit/egit/+/190776
Comment 15 Thomas Wolf CLA 2022-02-18 12:58:28 EST
(In reply to Eclipse Genie from comment #14)
> Gerrit change https://git.eclipse.org/r/c/egit/egit/+/190776 was merged to
> [master].
> Commit:
> http://git.eclipse.org/c/egit/egit.git/commit/
> ?id=c72ac1197d68ae78d893e4c6b8f945a54b79ab22

With this change, "Push to Upstream" behaves like "git push" and opens dialogs if the git config is incomplete or ambiguous, or if it would push several branches.
Comment 16 Thomas Wolf CLA 2022-02-18 13:35:58 EST
*** Bug 575068 has been marked as a duplicate of this bug. ***
Comment 17 Thomas Wolf CLA 2022-02-18 13:41:34 EST
*** Bug 548915 has been marked as a duplicate of this bug. ***