Bug: Wrong upstream set

Steps to reproduce:

Preparation:

  1. Fresh repo:
    git init
    git add -all
    git commit -a -m "Initial commit"
    git push --set-upstream https://gitlab.com/example_group/example_subgroup/example_project.git master
  2. Create and switch to a new branch named beta tracking the current:
    git switch --track --create beta
    git push --set-upstream https://gitlab.com/example_group/example_subgroup/example_project.git beta
  3. Same as above but this time the new branch is named alpha:
    git switch --track --create alpha 
    git push --set-upstream https://gitlab.com/example_group/example_subgroup/example_project.git alpha
  4. Browse to the project on GitLab.
  5. Create an issue.
  6. Create a merge request using that issue, and select the alpha branch as source branch.

I have already done the above at @trimoon-inc/system/archiso_setup 😉 https://gitlab.com/trimoon-inc/system/archiso_setup

The bug:

  1. Pull the project on your machine to get the updates.
    git pull
  2. Grab that merge request using your util.
    git mr 1
  3. Check the configured merge value in your cloned repo of this new branch.
    If you cloned the repo I prepared, it will show refs/heads/1-improve-alpha-version\nHEAD\nalpha\nbeta\nmaster which is wrong 😉
  4. It should be refs/heads/1-improve-alpha-version
    Note the \nHEAD\nalpha\nbeta\nmaster at end of the wrong value 👍

Evidence of bad value:

You won't be able to check the status of the branch relative to the upstream using git status

Edited by Elan Ruusamäe