FredrikNoren / ungit

The easiest way to use git. On any platform. Anywhere.
MIT License
10.45k stars 640 forks source link

Pushing to a remote branch with a slash in the name fails #271

Closed lh-gbelger closed 10 years ago

lh-gbelger commented 10 years ago

Pushing to a branch with the name "feature/feature1" failes with this error:

Error: Command failed: error: there are still refs under 'refs/heads/feature'
remote: error: failed to lock refs/heads/feature
To git@mywebgit:myproject.git
 ! [remote rejected] feature/feature1 -> feature (failed to lock)
error: failed to push some refs to 'git@mywebgit:myproject.git'

When looking at the command used:

git -c color.ui=false -c core.quotepath=false -c core.pager=cat -c credential.helper="C:/Users/myuser/AppData/Roaming/npm/node_modules/ungit/bin/credentials-helper 32"  push origin feature/feature1:feature

it seems clear that the command was constructed incorectly and is trying to push "feature/feature1" to "feature". Digging into this a bit deaper I see that the push POST action is sending JSON that contains the incorrect remoteBranch data that may be triggering the later faulty command:

{
  "path":"C:\\projects\\moonshine",
  "remote":"origin",
  "refSpec":"feature/feature1",
  "remoteBranch":"feature",
  "socketId":32
}

And as a final inspection step it seems that the source file public/source/ref.js line 41 splits remote branch name by "/" and only holds onto the value at the 1 index.

FredrikNoren commented 10 years ago

Thanks for an awesome bug report! Fix will go out with the next version (though will be a few weeks before I can get a new version out)

lh-gbelger commented 10 years ago

it was easy to track it down with the good amount of error data the tool gives. Thanks for the quick fix!