Skip to content

Instantly share code, notes, and snippets.

@bhank
Created September 20, 2013 00:11
Show Gist options
  • Save bhank/6631617 to your computer and use it in GitHub Desktop.
Save bhank/6631617 to your computer and use it in GitHub Desktop.
A batch file to launch TortoiseProc.exe or TortoiseGitProc.exe as appropriate.
@ECHO OFF
SET FOUND=
SET SEARCHPATH=%CD%
SET LASTSEARCHPATH=
ECHO %~nx0: finding source control dir for %SEARCHPATH%
:loop
CALL :checkdir "%SEARCHPATH%"
IF NOT "%FOUND%"=="" GOTO %FOUND%
SET LASTSEARCHPATH=%SEARCHPATH%
FOR %%i IN ("%SEARCHPATH%\..") DO SET SEARCHPATH=%%~fi
IF "%SEARCHPATH%"=="%LASTSEARCHPATH%" goto notfound
GOTO loop
echo The End
GOTO :EOF
:checkdir
ECHO Checking %~f1
IF EXIST "%~f1\.git\." SET FOUND=git
IF EXIST "%~f1\.svn\." SET FOUND=svn
GOTO :EOF
:svn
echo It's svn!
echo Running: tortoiseproc.exe %*
start tortoiseproc.exe %*
goto :EOF
:git
echo It's git!
echo Running: tortoisegitproc.exe %*
start tortoisegitproc.exe %*
goto :EOF
:notfound
echo Not found!
exit /b 1
goto :EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment