On Fri, Jun 20, 2025 at 12:03 PM Johannes Schindelin
<johannes.schinde...@gmx.de> wrote:
>
> When running
>
>         CYGWIN=winsymlinks:nativestrict ln -s .. abc
>
> the counter-intuitive result is _not_ a symbolic link to `..`, but
> instead to `../../$(basename "$PWD")`.
>
> The reason for this is that the search for the longest common prefix
> assumes that the link target is not a strict prefix of the parent
> directory of the link itself.
>
> Let's fix that.
>
> Signed-off-by: Johannes Schindelin <johannes.schinde...@gmx.de>
> ---
> Published-As: 
> https://github.com/dscho/msys2-runtime/releases/tag/fix-dotdot-native_symlink-v1
> Fetch-It-Via: git fetch https://github.com/dscho/msys2-runtime 
> fix-dotdot-native_symlink-v1
>
>
>         I investigated a failure in the Git test suite and was quite
>         surprised that `ln -s .. dir/link-git` resulted in this:
>
>                 link-dir -> ../../trash\ directory.t1006-cat-file
>
>         instead of this:
>
>                 link-dir -> ..
>
>  winsup/cygwin/path.cc | 21 ++++++++++++++++-----
>  1 file changed, 16 insertions(+), 5 deletions(-)
>
> diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
> index 42919a7cf5..ed08398930 100644
> --- a/winsup/cygwin/path.cc
> +++ b/winsup/cygwin/path.cc
> @@ -1855,9 +1855,18 @@ symlink_native (const char *oldpath, path_conv 
> &win32_newpath)
>        while (towupper (*++c_old) == towupper (*++c_new))

1 unrelated issue:
I think this towupper() code is WRONG if the filesystem (e.g. WSL) is
case-sensitive!

How can code in cygwin.dll test whether the current path is on a
case-sensitive volume, or not? What if the perr-dir case-sensitive
feature is ON, should that be probed and handled too?

Sebi
-- 
Sebastian Feld - IT security consultant

-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

Reply via email to