~ubuntu-branches/ubuntu/trusty/psychtoolbox-3/trusty-proposed

« back to all changes in this revision

Viewing changes to Psychtoolbox/PsychOneliners/GetGitPath.m

  • Committer: Package Import Robot
  • Author(s): Yaroslav Halchenko
  • Date: 2013-11-19 23:34:50 UTC
  • mfrom: (3.1.4 experimental)
  • Revision ID: package-import@ubuntu.com-20131119233450-f7nf92vb8qavjmk8
Tags: 3.0.11.20131017.dfsg1-3
Upload to unsable since fresh glew has arrived to sid!

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
function gitpath = GetGitPath
 
2
% gitpath = GetGitPath -- Return auto-detected installation path
 
3
% for git client, if any. Return empty string if auto-detection not
 
4
% possible. Typical usage is like this:
 
5
%
 
6
% mygitcommand = [GetGitPath 'git describe']; system(mygitcommand);
 
7
%
 
8
% GetGitPath will return the path to be prefixed in front of the git
 
9
% executable. If none can be found, the git executable will be executed
 
10
% without path spec. If it is installed in the system executable search
 
11
% path, it will then still work.
 
12
%
 
13
% The function simply checks if the git executable is in the Matlab path
 
14
% and returns a proper path-spec. If it isn't found in the Matlab path, it
 
15
% tries default path locations for OS-X and Windows. If that doesn't work,
 
16
% it returns an empty string.
 
17
 
 
18
% History:
 
19
% 07/11/13 Written, based on GetSubversionPath (DHB).
 
20
 
 
21
% Check for alternative install location of Git:
 
22
if IsWin
 
23
    % Search for Windows executable in Matlab's path:
 
24
    gitpath = which('git.exe');
 
25
else
 
26
    % Search for Unix executable in Matlab's path:
 
27
    gitpath = which('git.');
 
28
end
 
29
 
 
30
% Found one?
 
31
if ~isempty(gitpath)
 
32
    % Extract basepath and use it:
 
33
    gitpath=[fileparts(gitpath) filesep];
 
34
else
 
35
    % Could not find git executable in Matlabs path. Check the default
 
36
    % install location on OS-X and abort if it isn't there. On M$-Win we
 
37
    % simply have to hope that it is in some system dependent search path.
 
38
    
 
39
    % Currently, we only know how to check this for Mac OSX.
 
40
    if IsOSX
 
41
        gitpath = '';
 
42
        
 
43
        if isempty(gitpath) && exist('/usr/bin/git','file')
 
44
            gitpath='/usr/bin/';
 
45
        end
 
46
        
 
47
        if isempty(gitpath) && exist('/usr/local/git/bin/git','file')
 
48
            gitpath='/usr/local/git/bin/';
 
49
        end
 
50
        
 
51
        if isempty(gitpath) && exist('/usr/local/bin/git','file')
 
52
            gitpath='/usr/local/bin/';
 
53
        end
 
54
        
 
55
        if isempty(gitpath) && exist('/bin/git','file')
 
56
            gitpath='/bin/';
 
57
        end
 
58
        
 
59
        if isempty(gitpath) && exist('/opt/local/bin/git', 'file')
 
60
            gitpath = '/opt/local/bin/';
 
61
        end
 
62
    end
 
63
end
 
64
 
 
65
return;