From 4915f5834dbb588836ad787e728cf4a81364f5af Mon Sep 17 00:00:00 2001 From: Felix Kollmann Date: Mon, 12 Mar 2018 15:03:36 +0100 Subject: Added support for non-symlink checkouts on Windows when elevated rights are missing This implementation mimicks the behavior of Git on Windows Signed-off-by: Felix Kollmann --- worktree_windows.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'worktree_windows.go') diff --git a/worktree_windows.go b/worktree_windows.go index d59448e..1bef6f7 100644 --- a/worktree_windows.go +++ b/worktree_windows.go @@ -3,6 +3,7 @@ package git import ( + "os" "syscall" "time" @@ -18,3 +19,17 @@ func init() { } } } + +func isSymlinkWindowsNonAdmin(err error) bool { + const ERROR_PRIVILEGE_NOT_HELD syscall.Errno = 1314 + + if err != nil { + if errLink, ok := err.(*os.LinkError); ok { + if errNo, ok := errLink.Err.(syscall.Errno); ok { + return errNo == ERROR_PRIVILEGE_NOT_HELD + } + } + } + + return false +} -- cgit