Re: [PATCH] remote-hg: fix path when cloning with tilde expansion
From: Felipe Contreras <hidden>
Date: 2016-06-15 22:58:23
On Fri, Aug 9, 2013 at 6:39 PM, Junio C Hamano [off-list ref] wrote:
Felipe Contreras [off-list ref] writes:quoted
On Fri, Aug 9, 2013 at 5:15 PM, Junio C Hamano [off-list ref] wrote:quoted
Felipe Contreras [off-list ref] writes:quoted
quoted
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