Merge branch 'maint'
[gc-utils.git] / src / gc-sh-setup.sh
blobb5a3e3af36009cf20c4571a349f9e51a9375a4fa
1 #!/bin/sh
2 # Copyright (c) 2008 David Soria Parra <dsp at php dot net>
4 # Licensed under the terms of the MIT License
5 # See /usr/share/doc/gcutils/copyright
6 # or http://www.opensource.org/licenses/mit-license.php
7 unset CDPATH
9 VERSION="$VERSION$"
10 PROGNAME="$PROGNAME$"
12 die()
14 echo >&2 "$@"
15 exit 127
18 check_git ()
20 git --version > /dev/null
22 if test $? != 0
23 then
24 die "Git not found. It's either not installed or not in \$PATH"
27 version=`git --version | grep -o -E "[12]\.([5]\.([0-9]{2,}|[3-9]+)|[6-9]\.[0-9]+)"`
28 if test -z "$version"
29 then
30 die "Wrong git version. $prog needs git 1.5.3 or higher, but "`git --version`" found."
34 version ()
36 echo "$PROGNAME: "`basename $0`-$VERSION
39 locate_git_repo ()
41 gitdir=`git rev-parse --git-dir 2> /dev/null`
42 test "$gitdir" = "" && die "Please use this command from a git working tree."
43 cd $gitdir/..