public static void setGitPath ( File path ) throws IOException , JavaGitException { if ( path != null ) { CheckUtilities . checkFileValidity ( path ) ; if ( ! ( path . isDirectory ( ) ) ) { throw new JavaGitException ( 020002 , ExceptionMessageMap . getMessage ( "020002" ) + " { path=[" + path . getPath ( ) + "] }" ) ; } } try { determineGitVersion ( path ) ; } catch ( Exception e ) { // The path that was passed in doesn't work. Catch any errors and throw this one instead. throw new JavaGitException ( 100002 , ExceptionMessageMap . getMessage ( "100002" ) + " { path=[" + path . getPath ( ) + "] }" , e ) ; } // Make sure we're hanging onto an absolute path. gitPath = ( path != null ) ? path . getAbsoluteFile ( ) : null ; }
Called when client code wants to explicitly tell us where to find git on their filesystem . If never called we assume that git is in a directory in the PATH environment variable for this process . Passing null as the path argument will unset an explicitly - set path and revert to looking for git in the PATH .