Convert symlinks to hardlinks on windows

This commit is contained in:
Noah committed 2019-11-25 11:04:37 -06:00
1 parent 986b8b2e8f
commit afa6850499
6 files changed
+29

No files matched your search

+1
View File
@@ -19,6 +19,7 @@ jobs:
architecture: 'x64'
- script: |
powershell.exe scripts/symlinks-to-hardlinks.ps1
"C:\Program Files\Git\mingw64\bin\curl.exe" -sSf -o rustup-init.exe https://win.rustup.rs/
.\rustup-init.exe -y
set PATH=%PATH%;%USERPROFILE%\.cargo\bin
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+28
View File
@@ -0,0 +1,28 @@
#!/usr/bin/env powershell
git ls-files -s | Select-String '^120000' | ConvertFrom-String -PropertyNames Get-Content,Hash,_,Path | ForEach-Object {
$symlink = $_.Path
git checkout --quiet -- $symlink
if (Test-Path $symlink -PathType Leaf) {
$parent = (Get-Item $symlink).Directory
} else {
$parent = (Get-Item $symlink).Parent
}
$child = (Get-Content $symlink)
$src = (Join-Path -Path $parent -ChildPath $child)
if (Test-Path $src -PathType Leaf) {
Remove-Item $symlink
New-Item -ItemType HardLink -Name $symlink -Value $src
} elseif (Test-Path $src -PathType Container) {
Remove-Item $symlink
New-Item -ItemType Junction -Name $symlink -Value $src
} else {
Write-Error 'error: git-rm-symlink: Not a valid source\n'
Write-Error '$symlink =/=> $src...'
return
}
git update-index --assume-unchanged $symlink
}