* Bug in get_pwd_cwd() in Windows?
@ 2014-07-21 14:13 Duy Nguyen
2014-07-22 19:35 ` René Scharfe
0 siblings, 1 reply; 4+ messages in thread
From: Duy Nguyen @ 2014-07-21 14:13 UTC (permalink / raw)
To: Git Mailing List
This function tests if $PWD is the same as getcwd() using st_dev and
st_ino. But on Windows these fields are always zero
(mingw.c:do_lstat). If cwd is moved away, I think falling back to $PWD
is wrong. I don't understand the use of $PWD in the first place.
1b9a946 (Use nonrelative paths instead of absolute paths for cloned
repositories - 2008-06-05) does not explain much.
--
Duy
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Bug in get_pwd_cwd() in Windows?
2014-07-21 14:13 Bug in get_pwd_cwd() in Windows? Duy Nguyen
@ 2014-07-22 19:35 ` René Scharfe
2014-07-23 11:53 ` Duy Nguyen
0 siblings, 1 reply; 4+ messages in thread
From: René Scharfe @ 2014-07-22 19:35 UTC (permalink / raw)
To: Duy Nguyen, Git Mailing List
Am 21.07.2014 16:13, schrieb Duy Nguyen:
> This function tests if $PWD is the same as getcwd() using st_dev and
> st_ino. But on Windows these fields are always zero
> (mingw.c:do_lstat). If cwd is moved away, I think falling back to $PWD
> is wrong. I don't understand the use of $PWD in the first place.
> 1b9a946 (Use nonrelative paths instead of absolute paths for cloned
> repositories - 2008-06-05) does not explain much.
The commit message reads:
Particularly for the "alternates" file, if one will be created, we
want a path that doesn't depend on the current directory, but we want
to retain any symlinks in the path as given and any in the user's view
of the current directory when the path was given.
The intent of the patch seems to be to prefer $PWD if it points to the
same directory as the one returned by getcwd() in order to preserve "the
user's view". That's why it introduces make_nonrelative_path() (now
called absolute_path()), in contrast to make_absolute_path() (now called
real_path()).
I imagine it's useful e.g. if your home is accessed through a symlink:
/home/foo -> /some/boring/mountpoint
Then real_path("bar") would give you "/some/boring/mountpoint/bar",
while absolute_path("bar") returned "/home/foo/bar". Not resolving
symlinks keeps the path friendly in this case. And it keeps working
even after the user's home is migrated to /a/bigger/partition and
/home/foo is updated accordingly.
René
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Bug in get_pwd_cwd() in Windows?
2014-07-22 19:35 ` René Scharfe
@ 2014-07-23 11:53 ` Duy Nguyen
2014-07-23 12:40 ` Karsten Blees
0 siblings, 1 reply; 4+ messages in thread
From: Duy Nguyen @ 2014-07-23 11:53 UTC (permalink / raw)
To: René Scharfe; +Cc: Git Mailing List
On Wed, Jul 23, 2014 at 2:35 AM, René Scharfe <l.s.r@web.de> wrote:
> Am 21.07.2014 16:13, schrieb Duy Nguyen:
>
>> This function tests if $PWD is the same as getcwd() using st_dev and
>> st_ino. But on Windows these fields are always zero
>> (mingw.c:do_lstat). If cwd is moved away, I think falling back to $PWD
>> is wrong. I don't understand the use of $PWD in the first place.
>> 1b9a946 (Use nonrelative paths instead of absolute paths for cloned
>> repositories - 2008-06-05) does not explain much.
>
>
> The commit message reads:
>
> Particularly for the "alternates" file, if one will be created, we
> want a path that doesn't depend on the current directory, but we want
> to retain any symlinks in the path as given and any in the user's view
> of the current directory when the path was given.
>
> The intent of the patch seems to be to prefer $PWD if it points to the same
> directory as the one returned by getcwd() in order to preserve "the user's
> view". That's why it introduces make_nonrelative_path() (now called
> absolute_path()), in contrast to make_absolute_path() (now called
> real_path()).
>
> I imagine it's useful e.g. if your home is accessed through a symlink:
>
> /home/foo -> /some/boring/mountpoint
>
> Then real_path("bar") would give you "/some/boring/mountpoint/bar", while
> absolute_path("bar") returned "/home/foo/bar". Not resolving symlinks keeps
> the path friendly in this case. And it keeps working even after the user's
> home is migrated to /a/bigger/partition and /home/foo is updated
> accordingly.
If it's saved back, then yes it's useful. And I think that's the case
in clone.c. I was tempted to remove this code (because it only works
if you stand at worktree's root dir anyway, else cwd is moved) but I
guess we can just disable this code on Windows only instead.
--
Duy
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Bug in get_pwd_cwd() in Windows?
2014-07-23 11:53 ` Duy Nguyen
@ 2014-07-23 12:40 ` Karsten Blees
0 siblings, 0 replies; 4+ messages in thread
From: Karsten Blees @ 2014-07-23 12:40 UTC (permalink / raw)
To: Duy Nguyen, René Scharfe; +Cc: Git Mailing List
Am 23.07.2014 13:53, schrieb Duy Nguyen:
> On Wed, Jul 23, 2014 at 2:35 AM, René Scharfe <l.s.r@web.de> wrote:
>> Am 21.07.2014 16:13, schrieb Duy Nguyen:
>>
>>> This function tests if $PWD is the same as getcwd() using st_dev and
>>> st_ino. But on Windows these fields are always zero
>>> (mingw.c:do_lstat). If cwd is moved away, I think falling back to $PWD
>>> is wrong. I don't understand the use of $PWD in the first place.
>>> 1b9a946 (Use nonrelative paths instead of absolute paths for cloned
>>> repositories - 2008-06-05) does not explain much.
>>
>>
>> The commit message reads:
>>
>> Particularly for the "alternates" file, if one will be created, we
>> want a path that doesn't depend on the current directory, but we want
>> to retain any symlinks in the path as given and any in the user's view
>> of the current directory when the path was given.
>>
>> The intent of the patch seems to be to prefer $PWD if it points to the same
>> directory as the one returned by getcwd() in order to preserve "the user's
>> view". That's why it introduces make_nonrelative_path() (now called
>> absolute_path()), in contrast to make_absolute_path() (now called
>> real_path()).
>>
>> I imagine it's useful e.g. if your home is accessed through a symlink:
>>
>> /home/foo -> /some/boring/mountpoint
>>
>> Then real_path("bar") would give you "/some/boring/mountpoint/bar", while
>> absolute_path("bar") returned "/home/foo/bar". Not resolving symlinks keeps
>> the path friendly in this case. And it keeps working even after the user's
>> home is migrated to /a/bigger/partition and /home/foo is updated
>> accordingly.
>
> If it's saved back, then yes it's useful. And I think that's the case
> in clone.c. I was tempted to remove this code (because it only works
> if you stand at worktree's root dir anyway, else cwd is moved) but I
> guess we can just disable this code on Windows only instead.
>
It is disabled on Windows as of 7d092adc get_pwd_cwd(): Do not trust st_dev/st_ino blindly
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-07-23 12:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-21 14:13 Bug in get_pwd_cwd() in Windows? Duy Nguyen
2014-07-22 19:35 ` René Scharfe
2014-07-23 11:53 ` Duy Nguyen
2014-07-23 12:40 ` Karsten Blees
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).