git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [msysGit] [PATCH] Installer: Create builtins as symbolic links on Vista
@ 2010-01-15 22:06 Michael Lukashov
  2010-01-16  0:41 ` Johannes Schindelin
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Lukashov @ 2010-01-15 22:06 UTC (permalink / raw)
  To: msysgit; +Cc: Michael Lukashov, git, Sebastian Schuberth, Johannes Schindelin

When create builtins, first try to use CreateSymbolicLinkW function.
If symbolic link creating fails, hard links are created.

Tested under WinXP (both FAT32 and NTFS), Vista and Win7.

This patch applies on top of ss/installer-improvements branch.

Signed-off-by: Michael Lukashov <michael.lukashov@gmail.com>
---
 share/WinGit/install.iss |   30 ++++++++++++++++++++++++------
 1 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/share/WinGit/install.iss b/share/WinGit/install.iss
index 91eac9c..f64f754 100644
--- a/share/WinGit/install.iss
+++ b/share/WinGit/install.iss
@@ -83,8 +83,10 @@ Type: dirifempty; Name: {app}\home
 
 // Note: Since we are using the Unicode version of Inno Setup, "String" is a Unicode
 // string, and thus we need to call the "W" (Wide-String) Windows API variant.
+function CreateSymbolicLink(lpFileName,lpExistingFileName:String;lpSecurityAttributes:Integer):Boolean;
+external 'CreateSymbolicLinkW@Kernel32.dll stdcall setuponly delayload';
 function CreateHardLink(lpFileName,lpExistingFileName:String;lpSecurityAttributes:Integer):Boolean;
-external 'CreateHardLinkW@Kernel32.dll stdcall setuponly';
+external 'CreateHardLinkW@Kernel32.dll stdcall setuponly delayload';
 
 const
     // Git Path options.
@@ -474,7 +476,11 @@ var
     IsNTFS:Boolean;
     FindRec:TFindRec;
     RootKey:Integer;
+    Version:TWindowsVersion;
+    LinkCreated:Boolean;
 begin
+    GetWindowsVersionEx(Version);
+
     if CurStep<>ssPostInstall then begin
         Exit;
     end;
@@ -511,13 +517,25 @@ begin
             for i:=0 to Count do begin
                 FileName:=AppDir+'\'+BuiltIns[i];
 
-                // On non-NTFS partitions, create hard links.
-                if (FileExists(FileName) and (not DeleteFile(FileName))) or
-                   (not CreateHardLink(FileName,AppDir+'\bin\git.exe',0)) then begin
-                    Log('Line {#emit __LINE__}: Unable to create hard link "'+FileName+'", will try to copy files.');
-                    IsNTFS:=False;
+                // First check if file exists.
+                if (FileExists(FileName) and (not DeleteFile(FileName))) then begin
+                    Log('Line {#emit __LINE__}: Unable to delete file "'+FileName);
                     Break;
                 end;
+                // Try to create symbolic link
+                if Version.Major>=6 then
+                try
+                  LinkCreated:=CreateSymbolicLink(FileName,AppDir+'\bin\git.exe',0);
+                except
+                  LinkCreated:=False;
+                end;
+                // Try to create hard link
+                if (not LinkCreated) and
+                   (not CreateHardLink(FileName,AppDir+'\bin\git.exe',0)) then begin
+                  Log('Line {#emit __LINE__}: Unable to create hard link "'+FileName+'", will try to copy files.');
+                  IsNTFS:=False;
+                  Break;
+                end;
             end;
 
             Log('Line {#emit __LINE__}: Successfully created built-in aliases as hard links.');
-- 
1.6.6.1536.g1ac8c

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [msysGit] [PATCH] Installer: Create builtins as symbolic links on Vista
  2010-01-15 22:06 [msysGit] [PATCH] Installer: Create builtins as symbolic links on Vista Michael Lukashov
@ 2010-01-16  0:41 ` Johannes Schindelin
  0 siblings, 0 replies; 2+ messages in thread
From: Johannes Schindelin @ 2010-01-16  0:41 UTC (permalink / raw)
  To: Michael Lukashov; +Cc: msysgit, git, Sebastian Schuberth

Hi,

On Fri, 15 Jan 2010, Michael Lukashov wrote:

> When create builtins, first try to use CreateSymbolicLinkW function. If 
> symbolic link creating fails, hard links are created.
> 
> Tested under WinXP (both FAT32 and NTFS), Vista and Win7.
> 
> This patch applies on top of ss/installer-improvements branch.

The commit message is a wonderful place to convince readers that the 
patched code has a tremendous advantage over the existing code.

Maybe you forgot to add this discussion?

Ciao,
Dscho

P.S.: I am quite sure that the Git mailing list is maybe better suited for 
patches to the Git source code rather than for patches to the InnoSetup 
code of Git for Windows.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-01-16  0:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-15 22:06 [msysGit] [PATCH] Installer: Create builtins as symbolic links on Vista Michael Lukashov
2010-01-16  0:41 ` Johannes Schindelin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).