Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows: directory relative symlinks do not work #5252

Closed
ehuss opened this issue Oct 2, 2019 · 5 comments · Fixed by #5355
Closed

Windows: directory relative symlinks do not work #5252

ehuss opened this issue Oct 2, 2019 · 5 comments · Fixed by #5355

Comments

@ehuss
Copy link
Contributor

ehuss commented Oct 2, 2019

When cloning a repository with symbolic links, the links will end up with forward slashes. These files cannot be read using typical APIs like CreateFileW (without FILE_FLAG_OPEN_REPARSE_POINT) which result in ERROR_INVALID_NAME. This assumes you have core.symlinks to true and have the necessary developer mode enabled.

Reproduction steps

  1. Create a repository with a file symbolic link between directories. For example:
    • mkdir somedir
    • echo contents > somedir\foo
    • mklink foo somedir\foo
    • Init a repo, and add these two files
  2. Have a libgit2 project which will clone the sample repo.
  3. Notice that the resulting files have forward slashes, like this:
    10/01/2019 06:43 PM <SYMLINK> foo [somedir/foo]
    Also notice that these files cannot be opened using Windows apis (like in Notepad). Beware that msys tools (like cat) seem to be able to access them. I would guess that maybe they use FILE_FLAG_OPEN_REPARSE_POINT, read the link content, and translate the path manually.

Expected behavior

Should be able to open symlinked files on windows.

Actual behavior

Files fail to open.

Version of libgit2 (release number or SHA1)

08cfa43

Operating system(s) tested

Windows 10

@ethomson
Copy link
Member

ethomson commented Oct 2, 2019

Should be able to open symlinked files on windows.

What does Git for Windows do here? What are the files that it creates?

I ask because it's not clear to me if both systems need to be fixed or if this is a limitation of libgit2 only.

@ehuss
Copy link
Contributor Author

ehuss commented Oct 7, 2019

What does Git for Windows do here? What are the files that it creates?

It translates forward slashes to backslashes (source).

@ethomson
Copy link
Member

ethomson commented Oct 7, 2019

It translates forward slashes to backslashes (source).

Thanks for validating this, that makes sense and we should match their behavior indeed.

@Idanlu
Copy link

Idanlu commented Jan 7, 2020

Any news regarding this issue?

@pks-t
Copy link
Member

pks-t commented Jan 10, 2020

Now there is: #5355. Thanks for your ping, @Idanlu!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants