felipec / git

Fork of Junio Hamano's git for users
Other
204 stars 34 forks source link

push failed when git branch is different than bzr branch name #52

Closed zazabe closed 10 years ago

zazabe commented 10 years ago

Hi,

I can't push to bzr when my git branch is different than the bzr branch:

# create bzr repo
bzr init-repo bzr-repo ; bzr init bzr-repo/foo 
cd bzr-repo/foo ; echo a > a ; bzr add a ; bzr commit -m 'init a'               
cd ../../

# create git repo
git init git-repo 
cd git-repo/

# add bzr remote
git remote add bzr bzr::/tmp/demo/bzr-repo
git config remote.bzr.bzr-branches foo
git remote update bzr

# checkout bzr branch with another name
git checkout --track -b bar bzr/foo

# try to push some changes to bzr...
echo b > b ; git add b ; git commit -m 'commit b'
git push bzr HEAD:foo

# output:
Traceback (most recent call last):
  File "/usr/bin/git-remote-bzr", line 947, in <module>
    sys.exit(main(sys.argv))
  File "/usr/bin/git-remote-bzr", line 933, in main
    do_export(parser)
  File "/usr/bin/git-remote-bzr", line 670, in do_export
    parse_commit(parser)
  File "/usr/bin/git-remote-bzr", line 585, in parse_commit
    branch = get_remote_branch(name)
  File "/usr/bin/git-remote-bzr", line 762, in get_remote_branch
    remote_branch = bzrlib.branch.Branch.open(branches[name])
KeyError: 'bar'

It's work fine if i do this instead:

# checkout bzr branch with the same name
git checkout --track -b foo bzr/foo
echo b > b ; git add b ; git commit -m 'commit b'
git push

# output
All changes applied successfully.
To bzr::/tmp/demo/bzr-repo
   3aaf539..17fa622  foo -> foo

Is there any way to have a different name for my git branch ?

Thanks

felipec commented 10 years ago

This works fine for me:

git push bzr bar:foo

However, I'm using git-fc, you are probably using upstream git, which hasn't included the required patch series:

http://thread.gmane.org/gmane.comp.version-control.git/237663/focus=237668

So the problem is in Git.

felipec commented 10 years ago

I've pushed a fix to make HEAD:foo works. The problem is again on Git's core.

To bzr::/tmp/demo/bzr-repo
   436afa5..41ce12e  HEAD -> foo