Skip to content
Browse files

fix calculating of git_dir when invoked via "git clone"

  • Loading branch information...
1 parent b1a0087 commit b1cc3494fcb211b42dc3b474e83a78afbe9c99cb Ryan Kelly committed
Showing with 6 additions and 2 deletions.
  1. +6 −2 git_remote_hg/__init__.py
View
8 git_remote_hg/__init__.py
@@ -97,7 +97,11 @@ def main(argv=None, git_dir=None):
if argv is None:
argv = sys.argv
if git_dir is None:
+ git_dir = os.environ.get("GIT_DIR", None)
+ if git_dir is None:
git_dir = os.getcwd()
+ if os.path.exists(os.path.join(git_dir, ".git")):
+ git_dir = os.path.join(git_dir, ".git")
# AFAICT, we always get the hg repo url as the second argument.
hg_url = argv[2]
@@ -148,7 +152,7 @@ class HgGitCheckout(object):
def __init__(self, git_dir, hg_url):
self.hg_url = hg_url
self.hg_name = hg_name = urllib.quote(hg_url, safe="")
- self.hg_repo_dir = os.path.join(git_dir, ".git", "hgremotes", hg_name)
+ self.hg_repo_dir = os.path.join(git_dir, "hgremotes", hg_name)
if not os.path.exists(self.hg_repo_dir):
self.initialize_hg_repo()
self.git_repo_dir = os.path.join(self.hg_repo_dir, ".hg", "git")
@@ -160,7 +164,7 @@ def _do(self, *cmd, **kwds):
p = subprocess.Popen(cmd, **kwds)
output = p.stdout.readline()
while output:
- print>>sys.stderr, "hg :: " + output
+ print>>sys.stderr, "hg :: " + output.strip()
output = p.stdout.readline()
p.wait()

0 comments on commit b1cc349

Please sign in to comment.
Something went wrong with that request. Please try again.