Subject: Re: GIT on MinGW problem

From: Marius Storm-Olsen <[email-masked]>
Date: Tue, 29 May 2007 15:05:26 +0200

Johannes Schindelin said the following on 29.05.2007 14:11:
>> Also, the /bin/gitk.bat file should rather be 
>> @"%~d0%~p0wish84.exe" "%~d0%~p0gitk" %* than the current
>> hardcoded path. (Probably won't work with command.com, but who
>> uses that for development nowadays anyways, right ;-)
> 
> We're open source, so we _can_ do better than leaving people stuck
> on older hardware behind.
> 
> And I don't know what this garbage means. (I checked with GMane,
> and it looks the same there.) I'd rather have something readable,
> even if it is slightly slower or has to be adjusted when
> installing.

%~d0 = expands %0 to a drive letter only
%~p0 = expands %0 to a path only

so, for
     C:\foo\bar\baz\gitk.bat
%~d0%~p0gitk would expand to
     C:\foo\bar\baz\gitk

Looking at the docs for cmd's call (run 'help call'), I see now that 
it can be written
     %~dp0gitk
as well..

Anyways, if people are critical to not supporting the command.com, 
then you could do something like the following. (Note that for 
command.com it would be the old behavior were you need to replace the 
path if you install Git somewhere else, while for cmd.exe users it 
will just work. I'm sure magic can be done to make it work with 
command.com as well, but I'll leave that up to someone else to play with):

---
@echo off
REM This GOTO relies on the hack that command.com only supports
REM 8 character labels, so it reads 'goto _Windows'
goto :_WindowsNT

REM Command.com jumps here
:_Windows
wish84.exe "C:\Git\usr\bin\gitk" %1 %2 %3 %4 %5 %6 %7 %8 %9
REM NOTE! If you install Git in some other path, and use
REM command.com, you need to replace the path above

goto :EOF

REM Cmd.exe jumps here
:_WindowsNT
start wish84.exe "%~dp0gitk" %*

:EOF

-- 
.marius