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

Cloning a repo on Windows breaks symlinks #4107

Closed
bquistorff opened this issue Feb 3, 2017 · 5 comments
Closed

Cloning a repo on Windows breaks symlinks #4107

bquistorff opened this issue Feb 3, 2017 · 5 comments

Comments

@bquistorff
Copy link

I can't clone faithfully repos with symlinks on Windows. I have been able to do this using Git for Windows (info) when in Administrator mode and setting core.symlinks=true.

Reproduction steps

I am using libgit2 through R with the git2r package.
Start R in administrator mode

> git2r::config()
programdata:
        color.branch=auto
        color.diff=auto
        color.interactive=true
        color.status=auto
        core.autocrlf=true
        core.fscache=true
        core.symlinks=true
        diff.astextplain.textconv=astextplain
        help.format=html
        http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
        rebase.autosquash=true
global:
        core.symlinks=true
        filter.lfs.clean=git-lfs clean -- %f
        filter.lfs.process=git-lfs filter-process
        filter.lfs.required=true
        filter.lfs.smudge=git-lfs smudge -- %f
> git2r::clone("git://github.com/imbs-hl/ranger.git", "C:/Users/USER/Documents/GitHub/ranger2", progress = FALSE)
Local:    master C:/Users/USER/Documents/GitHub/ranger2/
Remote:   master @ origin (git://github.com/imbs-hl/ranger.git)
Head:     [47eb75a] 2017-01-20: Merge pull request #157 from imbs-hl/fix_extratrees

Expected behavior

Expect many symlink files in ranger-r-package/ranger/src folder.

Actual behavior

Many text files in ranger-r-package/ranger/src folder where file contents are the original symlink target paths.

Version of libgit2 (release number or SHA1)

git2r version 0.18.0.9000 (latest release) which say that it has libgit2 commit 6b0510e from 20 December 2016

Operating system(s) tested

Windows 10 Enterprise

@ethomson
Copy link
Member

ethomson commented Feb 8, 2017

I truly dislike the core.symlinks option, but I suppose it's something that we should indeed support. (To be honest, though, this isn't really on my radar at the moment.)

@csware
Copy link
Contributor

csware commented Mar 20, 2017

I just want to add that symlinks on Windows require a local Administrator and administrative privileges (elevated mode by default, but the right to create sylinks can also be granted to "normal" users, at least with Win10; https://blogs.windows.com/buildingapps/2016/12/02/symlinks-windows-10/).

Please also see https://github.com/git-for-windows/git/wiki/Symbolic-Links on how Git for Windows handles symlinks.

@jabbera
Copy link

jabbera commented Jun 14, 2017

@csware the admin requirement is no longer needed for windows 10 creators.

@cyberbit
Copy link

@jabbera But only if the user has Developer Mode enabled.

mbland added a commit to bats-core/bats-core that referenced this issue Jun 7, 2018
Closes #90. Closes #83. Closes #56. Closes #55. Closes #53. Resolves
outstanding issues from #32.

Per all these earlier issues and PRs:

- The original bin/bats symlink was causing problems on Windows.
- The attempted fix from #32 created problems for install.sh.
- Per #90, changing bin/bats to a one-line script in #88 broke some Bats
  installations that rely on symlink schemes (such as when installed via
  https://github.com/basherpm/basher).

For an idea why I wanted to abolish using any symlinks if I could for
Windows's sake, see the following results I discovered during a search
for "git symlink windows":

- https://github.com/git-for-windows/git/wiki/Symbolic-Links
- https://blogs.windows.com/buildingapps/2016/12/02/symlinks-windows-10/
- libgit2/libgit2#4107
- https://stackoverflow.com/q/5917249

Using a method inspired by go-core.bash from
https://github.com/mbland/go-script-bash, I was able to reliably compute
the root of the Bats installation without using `readlink` by making use
of `PWD` and `cd`.

What's more, in the course of doing this, I realized libexec/bats didn't
need `readlink` either, so I removed it, eliminating external
dependencies and subshells. I also removed some extraneous variables and
small bits of logic.

On top of making install.sh, bin/bats, and libexec/bats more
self-contained, resilient, and compact, the existing test suite (before
the new installer and symlink tests) sped up significantly, running
0.6s-0.7s faster on my MacBook Pro (2.9 GHz Intel Core i5, 8GB RAM):

  Bash 3.2.57(1)-release before:
  58 tests, 0 failures

  real    0m4.924s
  user    0m3.045s
  sys     0m1.798s

  Bash 3.2.57(1)-release after:
  58 tests, 0 failures

  real    0m4.326s
  user    0m2.793s
  sys     0m1.508s

  Bash 4.4.23(1)-release before:
  58 tests, 0 failures

  real    0m5.228s
  user    0m3.046s
  sys     0m1.952s

  Bash 4.4.23(1)-release after:
  58 tests, 0 failures

  real    0m4.563s
  user    0m2.782s
  sys     0m1.614s
mbland added a commit to bats-core/bats-core that referenced this issue Jun 7, 2018
Closes #90. Closes #83. Closes #56. Closes #55. Closes #53. Resolves
outstanding issues from #32.

Per all these earlier issues and PRs:

- The original bin/bats symlink was causing problems on Windows.
- The attempted fix from #32 created problems for install.sh.
- Per #90, changing bin/bats to a one-line script in #88 broke some Bats
  installations that rely on symlink schemes (such as when installed via
  https://github.com/basherpm/basher).

For an idea why I wanted to abolish using any symlinks if I could for
Windows's sake, see the following results I discovered during a search
for "git symlink windows":

- https://github.com/git-for-windows/git/wiki/Symbolic-Links
- https://blogs.windows.com/buildingapps/2016/12/02/symlinks-windows-10/
- libgit2/libgit2#4107
- https://stackoverflow.com/q/5917249

Using a method inspired by go-core.bash from
https://github.com/mbland/go-script-bash, I was able to reliably compute
the root of the Bats installation without using `readlink` by making use
of `PWD` and `cd`.

What's more, in the course of doing this, I realized libexec/bats didn't
need `readlink` either, so I removed it, eliminating external
dependencies and subshells. I also removed some extraneous variables and
small bits of logic.

On top of making install.sh, bin/bats, and libexec/bats more
self-contained, resilient, and compact, the existing test suite (before
the new installer and symlink tests) sped up significantly, running
0.6s-0.7s faster on my MacBook Pro (2.9 GHz Intel Core i5, 8GB RAM):

  Bash 3.2.57(1)-release before:
  58 tests, 0 failures

  real    0m4.924s
  user    0m3.045s
  sys     0m1.798s

  Bash 3.2.57(1)-release after:
  58 tests, 0 failures

  real    0m4.326s
  user    0m2.793s
  sys     0m1.508s

  Bash 4.4.23(1)-release before:
  58 tests, 0 failures

  real    0m5.228s
  user    0m3.046s
  sys     0m1.952s

  Bash 4.4.23(1)-release after:
  58 tests, 0 failures

  real    0m4.563s
  user    0m2.782s
  sys     0m1.614s

Also tweaks the Dockerfile to update the symlink to point to bin/bats,
not libexec/bats.
mbland added a commit to bats-core/bats-core that referenced this issue Jun 7, 2018
Closes #90. Closes #83. Closes #56. Closes #55. Closes #53. Resolves
outstanding issues from #32.

Per all these earlier issues and PRs:

- The original bin/bats symlink was causing problems on Windows.
- The attempted fix from #32 created problems for install.sh.
- Per #90, changing bin/bats to a one-line script in #88 broke some Bats
  installations that rely on symlink schemes (such as when installed via
  https://github.com/basherpm/basher).

For an idea of why I wanted to keep bin/bats as a script due to how
symlinks complicate things on Windows, see the following results I
discovered during a search for "git symlink windows":

- https://github.com/git-for-windows/git/wiki/Symbolic-Links
- https://blogs.windows.com/buildingapps/2016/12/02/symlinks-windows-10/
- libgit2/libgit2#4107
- https://stackoverflow.com/q/5917249

In the course of applying these changes, I realized libexec/bats
computed some extraneous variables, so I removed them, eliminating a few
external processes and subshells. I also cleaned up other small bits of
logic.

On top of making install.sh, bin/bats, and libexec/bats more resilient
and compact, the existing test suite (before adding the new
test/installer.bats file) sped up significantly, running 0.6s-0.7s
faster on my MacBook Pro (2.9 GHz Intel Core i5, 8GB RAM):

  Bash 3.2.57(1)-release before:
  58 tests, 0 failures

  real    0m4.924s
  user    0m3.045s
  sys     0m1.798s

  Bash 3.2.57(1)-release after:
  58 tests, 0 failures

  real    0m4.341s
  user    0m2.808s
  sys     0m1.540s

  Bash 4.4.23(1)-release before:
  58 tests, 0 failures

  real    0m5.228s
  user    0m3.046s
  sys     0m1.952s

  Bash 4.4.23(1)-release after:
  58 tests, 0 failures

  real    0m4.582s
  user    0m2.791s
  sys     0m1.643s

Also tweaks the Dockerfile to update the symlink to point to bin/bats,
not libexec/bats.
@ethomson
Copy link
Member

Support was added in #4713

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

No branches or pull requests

5 participants