Fix double quotes in a string comparision
[gc-utils.git] / gc-commit.sh
blob81d742de37d2b1c69b9adf173e040248c1b88f26
1 #!/bin/sh
2 # Copyright (c) 2007 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 VERSION="$VERSION$"
8 PROGNAME="$PROGNAME$"
10 check_git ()
13 git --version > /dev/null
15 if test $? != 0
16 then
17 echo >&2 "Git not found. It's either not installed or not in \$PATH"
18 exit 127
21 version=`git --version | grep -o "[12]\.[5-9]\.[0-9]"`
22 if test -z "$version"
23 then
24 echo "Wrong git version. $prog needs git 1.5.0 or higher, but "`git --version`" found."
25 exit 127
29 version ()
31 echo "$PROGNAME: "`basename $0`-$VERSION
34 usage ()
36 echo "Usage:" `basename $0`" [OPTIONS] <sha1>"
37 echo "Options are:"
38 echo " -h show help"
39 echo " -C run a cvsclean. "
40 echo " WARNING: this will run cvs up -C"
41 echo " and then remove all found .#* files"
42 echo " -c commit to cvs if no errors occured"
43 echo " -f force patching in case of an unclean"
44 echo " cvs repository"
45 echo " -V show version information"
46 echo
47 exit 127
50 check_git
52 cvsclean=
53 commit=
54 force=
55 while test $# != 0
56 do
57 case "$1" in
58 -c)
59 commit="-c"
61 -C)
62 cvsclean=t
64 -f)
65 force="-f"
67 -h)
68 usage
70 -V)
71 version
72 exit
74 -*)
75 echo >&2 "Parameter $1 is not known."
76 usage
79 break
81 esac
82 shift
83 done
85 if test $# = 0 ; then
86 usage
90 if test "$cvsclean" = "t"
91 then
92 cd ".cvs" && cvs up -C && find . -iname ".#*" -exec rm '{}' \;
93 cd $OLDPWD
96 if test -d ".git" -a -d ".cvs"
97 then
98 cd ".cvs"
99 GIT_DIR="../.git" git-cvsexportcommit -v $force $commit -u $1
100 cd $OLDPWD
101 else
102 if test -d ".git"
103 then
104 echo >&2 "Not a git repository"
107 if test -d ".cvs"
108 then
109 echo >&2 "No cvs repository found in .cvs. "
110 echo >&2 "Make sure you follow the standards"