Respect $PATH while looking for git, thanks to grobian.
authoridl0r <idl0r@gentoo.org>
Fri, 1 May 2009 19:03:07 +0000 (19:03 -0000)
committeridl0r <idl0r@gentoo.org>
Fri, 1 May 2009 19:03:07 +0000 (19:03 -0000)
svn path=/; revision=570

trunk/src/echangelog/echangelog

index c267c28775bafd9e5237ab4b16db5d5a5b8f3a30..f4a0813749dc9a8c7884583c977825bef21ec853 100755 (executable)
@@ -104,10 +104,16 @@ if ( -d "CVS" ) {
 } elsif ( -d '.svn' ) {
        $vcs = "svn";
 } else {
-       if ( -x '/usr/bin/git' ) {
-               open(GIT, '-|', "git rev-parse --git-dir 2>/dev/null");
-               $vcs = "git" if defined(<GIT>);
-               close(GIT);
+       # Respect $PATH while looking for git
+       if (getenv("PATH")) {
+               foreach my $path ( split(":", getenv("PATH")) ) {
+                       if ( -X "$path/git" ) {
+                               open(GIT, '-|', "git rev-parse --git-dir 2>/dev/null");
+                               $vcs = "git" if defined(<GIT>);
+                               close(GIT);
+                               last;
+                       }
+               }
        }
 
        if ( ! $vcs ) {