{"thread":{"id":"22237","subject":"[msysGit] [PATCH] Installer: Create builtins as symbolic links on Vista","startedAt":"2010-01-15T22:06:59Z","lastAt":"2010-01-16T00:41:11Z","messageCount":2,"participants":["Michael Lukashov","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"131789","messageId":"1263593219-6032-1-git-send-email-michael.lukashov@gmail.com","threadId":"22237","inReplyTo":null,"subject":"[msysGit] [PATCH] Installer: Create builtins as symbolic links on Vista","fromName":"Michael Lukashov","fromEmail":"michael.lukashov@gmail.com","sentAt":"2010-01-15T22:06:59Z","receivedAt":"2010-01-15T22:06:59Z","isPatch":true,"sender":{"key":"michael.lukashov@gmail.com","avatar":"https://avatars.githubusercontent.com/u/890439?v=4"},"body":"When create builtins, first try to use CreateSymbolicLinkW function.\nIf symbolic link creating fails, hard links are created.\n\nTested under WinXP (both FAT32 and NTFS), Vista and Win7.\n\nThis patch applies on top of ss/installer-improvements branch.\n\nSigned-off-by: Michael Lukashov <michael.lukashov@gmail.com>\n---\n share/WinGit/install.iss |   30 ++++++++++++++++++++++++------\n 1 files changed, 24 insertions(+), 6 deletions(-)\n\ndiff --git a/share/WinGit/install.iss b/share/WinGit/install.iss\nindex 91eac9c..f64f754 100644\n--- a/share/WinGit/install.iss\n+++ b/share/WinGit/install.iss\n@@ -83,8 +83,10 @@ Type: dirifempty; Name: {app}\\home\n \n // Note: Since we are using the Unicode version of Inno Setup, \"String\" is a Unicode\n // string, and thus we need to call the \"W\" (Wide-String) Windows API variant.\n+function CreateSymbolicLink(lpFileName,lpExistingFileName:String;lpSecurityAttributes:Integer):Boolean;\n+external 'CreateSymbolicLinkW@Kernel32.dll stdcall setuponly delayload';\n function CreateHardLink(lpFileName,lpExistingFileName:String;lpSecurityAttributes:Integer):Boolean;\n-external 'CreateHardLinkW@Kernel32.dll stdcall setuponly';\n+external 'CreateHardLinkW@Kernel32.dll stdcall setuponly delayload';\n \n const\n     // Git Path options.\n@@ -474,7 +476,11 @@ var\n     IsNTFS:Boolean;\n     FindRec:TFindRec;\n     RootKey:Integer;\n+    Version:TWindowsVersion;\n+    LinkCreated:Boolean;\n begin\n+    GetWindowsVersionEx(Version);\n+\n     if CurStep<>ssPostInstall then begin\n         Exit;\n     end;\n@@ -511,13 +517,25 @@ begin\n             for i:=0 to Count do begin\n                 FileName:=AppDir+'\\'+BuiltIns[i];\n \n-                // On non-NTFS partitions, create hard links.\n-                if (FileExists(FileName) and (not DeleteFile(FileName))) or\n-                   (not CreateHardLink(FileName,AppDir+'\\bin\\git.exe',0)) then begin\n-                    Log('Line {#emit __LINE__}: Unable to create hard link \"'+FileName+'\", will try to copy files.');\n-                    IsNTFS:=False;\n+                // First check if file exists.\n+                if (FileExists(FileName) and (not DeleteFile(FileName))) then begin\n+                    Log('Line {#emit __LINE__}: Unable to delete file \"'+FileName);\n                     Break;\n                 end;\n+                // Try to create symbolic link\n+                if Version.Major>=6 then\n+                try\n+                  LinkCreated:=CreateSymbolicLink(FileName,AppDir+'\\bin\\git.exe',0);\n+                except\n+                  LinkCreated:=False;\n+                end;\n+                // Try to create hard link\n+                if (not LinkCreated) and\n+                   (not CreateHardLink(FileName,AppDir+'\\bin\\git.exe',0)) then begin\n+                  Log('Line {#emit __LINE__}: Unable to create hard link \"'+FileName+'\", will try to copy files.');\n+                  IsNTFS:=False;\n+                  Break;\n+                end;\n             end;\n \n             Log('Line {#emit __LINE__}: Successfully created built-in aliases as hard links.');\n-- \n1.6.6.1536.g1ac8c\n"},{"id":"131824","messageId":"alpine.DEB.1.00.1001160139070.4985@pacific.mpi-cbg.de","threadId":"22237","inReplyTo":"1263593219-6032-1-git-send-email-michael.lukashov@gmail.com","subject":"Re: [msysGit] [PATCH] Installer: Create builtins as symbolic links on Vista","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2010-01-16T00:41:11Z","receivedAt":"2010-01-16T00:41:11Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Fri, 15 Jan 2010, Michael Lukashov wrote:\n\n> When create builtins, first try to use CreateSymbolicLinkW function. If \n> symbolic link creating fails, hard links are created.\n> \n> Tested under WinXP (both FAT32 and NTFS), Vista and Win7.\n> \n> This patch applies on top of ss/installer-improvements branch.\n\nThe commit message is a wonderful place to convince readers that the \npatched code has a tremendous advantage over the existing code.\n\nMaybe you forgot to add this discussion?\n\nCiao,\nDscho\n\nP.S.: I am quite sure that the Git mailing list is maybe better suited for \npatches to the Git source code rather than for patches to the InnoSetup \ncode of Git for Windows.\n"}]}