Skip to content

Commit d82c912

Browse files
Felipe Contrerasgitster
authored andcommitted
remote-bzr: store converted URL
Bazaar might convert the URL to something more appropriate, like an absolute path. Lets store that instead of the original URL, which won't work from a different working directory if it's relative. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 6134caf commit d82c912

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

contrib/remote-helpers/git-remote-bzr

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import os
3232
import json
3333
import re
3434
import StringIO
35-
import atexit, shutil, hashlib
35+
import atexit, shutil, hashlib, urlparse, subprocess
3636

3737
NAME_RE = re.compile('^([^<>]+)')
3838
AUTHOR_RE = re.compile('^([^<>]+?)? ?<([^<>]*)>$')
@@ -713,6 +713,14 @@ def get_repo(url, alias):
713713

714714
return branch
715715

716+
def fix_path(alias, orig_url):
717+
url = urlparse.urlparse(orig_url, 'file')
718+
if url.scheme != 'file' or os.path.isabs(url.path):
719+
return
720+
abs_url = urlparse.urljoin("%s/" % os.getcwd(), orig_url)
721+
cmd = ['git', 'config', 'remote.%s.url' % alias, "bzr::%s" % abs_url]
722+
subprocess.call(cmd)
723+
716724
def main(args):
717725
global marks, prefix, dirname
718726
global tags, filenodes
@@ -741,6 +749,9 @@ def main(args):
741749
gitdir = os.environ['GIT_DIR']
742750
dirname = os.path.join(gitdir, 'bzr', alias)
743751

752+
if not is_tmp:
753+
fix_path(alias, url)
754+
744755
if not os.path.exists(dirname):
745756
os.makedirs(dirname)
746757

0 commit comments

Comments
 (0)