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

Re: Bug in get_pwd_cwd() in Windows?

From
Duy Nguyen <pclouds@gmail.com>
Date
Jul 23, 2014, 11:53 UTC
Message-ID
<CACsJy8Ch6FvWp-pOOG4-kDVmb+kyav7oromH8EpeEesPj7B9Yg@mail.gmail.com>
In-Reply-To
<53CEBD13.5040004@web.de>
On Wed, Jul 23, 2014 at 2:35 AM, René Scharfe <l.s.r@web.de> wrote:
Show 32 quoted lines
> 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
Previous: René ScharfeNext: Karsten Blees
Message 3 of 4 in “Bug in get_pwd_cwd() in Windows?”
  1. Duy NguyenJul 21, 2014
  2. René ScharfeJul 22, 2014
  3. Duy NguyenJul 23, 2014
  4. Karsten BleesJul 23, 2014

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.