Skip to content

Windows: directory relative symlinks do not work #5252

@ehuss

Description

@ehuss

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions