git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Antoine Pelisse <apelisse@gmail.com>
To: Felipe Contreras <felipe.contreras@gmail.com>
Cc: git@vger.kernel.org, Antoine Pelisse <apelisse@gmail.com>
Subject: [PATCH] remote-hg: fix path when cloning with tilde expansion
Date: Fri,  9 Aug 2013 19:13:07 +0200	[thread overview]
Message-ID: <1376068387-28510-1-git-send-email-apelisse@gmail.com> (raw)
In-Reply-To: <CAMP44s1Jqao0YvBSh18t1C2LwAF4_u2GaTNx1RwdW+pmCFcxvQ@mail.gmail.com>

The current code fixes the path to make it absolute when cloning, but
doesn't consider tilde expansion, so that scenario fails throwing an
exception because /home/myuser/~/my/repository doesn't exists:

    $ git clone hg::~/my/repository && cd repository && git fetch

Expand the tilde when checking if the path is absolute, so that we don't
fix a path that doesn't need to be.

Signed-off-by: Antoine Pelisse <apelisse@gmail.com>
---
On Mon, Aug 5, 2013 at 10:30 PM, Felipe Contreras <felipe.contreras@gmail.com> wrote:
> Shouldn't that be the job of the shell? (s/~/$HOME/)

I'm not sure what you mean here. Does it mean that I should stop cloning using "~" ?
I also send this patch as I think it makes more sense to keep the ~ in the path, but just make
sure we don't build invalid absolute path.

By the way, I don't exactly understand why:

    abs_url = urlparse.urljoin("%s/" % os.getcwd(), orig_url)

is done right after instead of:

    abs_url = os.path.abspath(orig_url)

Cheers,
Antoine

 contrib/remote-helpers/git-remote-hg |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg
index 1897327..861c498 100755
--- a/contrib/remote-helpers/git-remote-hg
+++ b/contrib/remote-helpers/git-remote-hg
@@ -1135,7 +1135,7 @@ def do_option(parser):

 def fix_path(alias, repo, orig_url):
     url = urlparse.urlparse(orig_url, 'file')
-    if url.scheme != 'file' or os.path.isabs(url.path):
+    if url.scheme != 'file' or os.path.isabs(os.path.expanduser(url.path)):
         return
     abs_url = urlparse.urljoin("%s/" % os.getcwd(), orig_url)
     cmd = ['git', 'config', 'remote.%s.url' % alias, "hg::%s" % abs_url]
--
1.7.9.5

  parent reply	other threads:[~2013-08-09 17:13 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-05 20:12 [PATCH] remote-hg: fix path when cloning with tilde expansion Antoine Pelisse
2013-08-05 20:30 ` Felipe Contreras
2013-08-05 20:32   ` Antoine Pelisse
2013-08-09 17:13   ` Antoine Pelisse [this message]
2013-08-09 18:49     ` Junio C Hamano
2013-08-09 20:09       ` Antoine Pelisse
2013-08-09 20:53         ` Junio C Hamano
2013-08-09 21:19           ` Antoine Pelisse
2013-08-09 21:45             ` Junio C Hamano
2013-08-09 21:55               ` Antoine Pelisse
2013-08-09 21:55             ` Felipe Contreras
2013-08-09 22:15               ` Junio C Hamano
2013-08-09 22:28                 ` Felipe Contreras
2013-08-09 23:39                   ` Junio C Hamano
2013-08-09 23:43                     ` Felipe Contreras
2013-08-10  5:18                       ` Junio C Hamano
2013-08-10  6:39                         ` Felipe Contreras
2013-08-10  6:50                           ` Junio C Hamano
2013-08-10  7:07                             ` Felipe Contreras
2013-08-10 15:15                               ` Antoine Pelisse

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1376068387-28510-1-git-send-email-apelisse@gmail.com \
    --to=apelisse@gmail.com \
    --cc=felipe.contreras@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).