termie / git-bzr-ng

bi-directional git to bzr bridge: never fear bzr again
BSD 3-Clause "New" or "Revised" License
198 stars 47 forks source link

git-bzr do not support using "/" in branch name #33

Open baby-gnu opened 12 years ago

baby-gnu commented 12 years ago

This is a git convention, as branch names are juste files under .git/refs/heads, every parts before last element must be a directory.

I implement a fix to create the parent directories as needed.

Regards.

git pull git://git.baby-gnu.net/git-bzr-ng dad/fix-git-style-branch-name-with-slashes

Subject: [PATCH] git-bzr do not support using "/" in branch name.

* git-bzr (cmd_import): Create parent directories of the bzr branch.

---
 git-bzr |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/git-bzr b/git-bzr
index 327d935..ff204f8 100755
--- a/git-bzr
+++ b/git-bzr
@@ -579,6 +579,10 @@ def cmd_import(args):
   if branch_exists(bzr_ref):
     die('Branch already exists: %s', bzr_ref)

+  # Permit git-style branch name with / in them
+  if not os.path.isdir(os.path.dirname(cl.bzr_dir(branch))):
+    os.makedirs(os.path.dirname(cl.bzr_dir(branch)))
+
   # Do the actual bzr fetch
   bzr(['branch', url, cl.bzr_dir(branch)])

-- 
1.7.7.3
christofferholmstedt commented 9 years ago

I just hit this when trying to push a branch with / in it. Didn't really understand the problem...now I do. I hit the problem when doing the following thing:

git checkout -b feature/new_awesome_feature
git bzr push lp:~<user>/<project>/<branch_with_forward_slash>

and got the following error:

bzr: ERROR: Parent of "<branch>" does not exist.
ERROR:root:Command "bzr branch <master> <branch>" failed.