From fa0f36b6942e09e4605cf2d878b3ff05e2492e9e Mon Sep 17 00:00:00 2001 From: blikblum Date: Fri, 1 Jun 2012 23:54:32 +0000 Subject: [PATCH] tools: check if git can be called (is in path) before calling it git-svn-id: trunk@37473 - --- tools/svn2revisioninc.pas | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/tools/svn2revisioninc.pas b/tools/svn2revisioninc.pas index 91f5712ea7..0bcb746974 100644 --- a/tools/svn2revisioninc.pas +++ b/tools/svn2revisioninc.pas @@ -89,6 +89,25 @@ var const RevisionIncComment = '// Created by Svn2RevisionInc'; + +function GitInPath: Boolean; +var + P: TProcessUTF8; +begin + Result := True; + P := TProcessUTF8.Create(nil); + try + P.Options := [poUsePipes, poWaitOnExit]; + P.CommandLine := 'git --version'; + try + P.Execute; + except + Result := False; + end; + finally + P.Destroy; + end; +end; function TSvn2RevisionApplication.FindRevision: boolean; var @@ -238,7 +257,7 @@ begin if not Result then begin GitDir:= AppendPathDelim(SourceDirectory)+'.git'; - if DirectoryExistsUTF8(GitDir) then + if DirectoryExistsUTF8(GitDir) and GitInPath then begin if IsThisGitUpstreamBranch then Result := GetRevisionFromGitVersion