git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] remote-hg: fix path when cloning with tilde expansion

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Aug 9, 2013, 23:43 UTC
Message-ID
<CAMP44s1Q2x9uz5Ajr=BgVjSjO88XD5UYzVSEqgMeK5_YAYSa5A@mail.gmail.com>
In-Reply-To
<7vmwoq304o.fsf@alter.siamese.dyndns.org>
On Fri, Aug 9, 2013 at 6:39 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 40 quoted lines
> Felipe Contreras <felipe.contreras@gmail.com> writes:
>
>> On Fri, Aug 9, 2013 at 5:15 PM, Junio C Hamano <gitster@pobox.com> wrote:
>>> Felipe Contreras <felipe.contreras@gmail.com> writes:
>>>
>>>>> OK, I think I see why you are puzzled.
>>>>>
>>>>> Cloning works fine because we "fix the path" *after* the clone is done
>>>>> successfully, for the following reason:
>>>>
>>>> So if we didn't store a different path, it would work. So instead of
>>>> expanding '~' ourselves, it would be better to don't expand anything,
>>>> and leave it as it is, but how to detect that in fix_path()?
>>>
>>> I think that the patch relies on that os.path.expanduser(), if
>>> url.path is such a path that begins with "~" (or "~whom"), returns
>>> an absolute path.  When given an absolute path, or "~whom/path",
>>> fix_path returns without running 'git config' on remote.<alias>.url
>>> configuration.
>>
>> I think ~whom/path would run 'git config'.
>
> Hmph, do you mean the third example of this?
>
>         $ python
>         >>> import os
>         >>> os.path.expanduser("~/repo")
>         '/home/junio/repo'
>         >>> os.path.expanduser("~junio/repo")
>         '/home/junio/repo'
>         >>> os.path.expanduser("~felipe/repo")
>         '~felipe/repo'
>
> which will give "~felipe/repo" that is _not_ an absolute repository
> because no such user exists on this box?
>
> It is true that in that case fix_path() will not return early and
> will throw a bogus path at "git config", but if the "~whom" does not
> resolve to an existing home directory of a user, I am not sure what
> we can do better than what Antoine's patch does.
I was thinking something like this:
if url.scheme != 'file' or os.path.isabs(url.path) or url.path[0] == '~':
  return
-- 
Felipe Contreras
Previous: Junio C HamanoNext: Junio C Hamano
Message 15 of 20 in “remote-hg: fix path when cloning with tilde expansion”
  1. remote-hg: fix path when cloning with tilde expansionAntoine Pelisse, Aug 5, 2013
  2. Felipe ContrerasAug 5, 2013
  3. Antoine PelisseAug 5, 2013
  4. remote-hg: fix path when cloning with tilde expansionAntoine Pelisse, Aug 9, 2013
  5. Junio C HamanoAug 9, 2013
  6. Antoine PelisseAug 9, 2013
  7. Junio C HamanoAug 9, 2013
  8. Antoine PelisseAug 9, 2013
  9. Junio C HamanoAug 9, 2013
  10. Antoine PelisseAug 9, 2013
  11. Felipe ContrerasAug 9, 2013
  12. Junio C HamanoAug 9, 2013
  13. Felipe ContrerasAug 9, 2013
  14. Junio C HamanoAug 9, 2013
  15. Felipe ContrerasAug 9, 2013
  16. Junio C HamanoAug 10, 2013
  17. Felipe ContrerasAug 10, 2013
  18. Junio C HamanoAug 10, 2013
  19. Felipe ContrerasAug 10, 2013
  20. Antoine PelisseAug 10, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.