Merge branch 'maint'
[gc-utils.git] / gc-commit.sh
blob80211a3c99f7013f722ce4c7a0eb1ab5d98b1f97
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
8 . $LIBDIR$/gc-sh-setup
10 usage ()
12 echo "Usage:" `basename $0`" [OPTIONS] <sha1>"
13 echo "Options are:"
14 echo " -h show help"
15 echo " -C run a cvsclean. "
16 echo " WARNING: this will run cvs up -C"
17 echo " and then remove all found .#* files"
18 echo " -c commit to cvs if no errors occured"
19 echo " -f force patching in case of an unclean"
20 echo " cvs repository"
21 echo " -V show version information"
22 echo
23 exit 127
26 check_git
28 cvsclean=
29 commit=
30 force=
31 while test $# != 0
32 do
33 case "$1" in
34 -c)
35 commit="-c"
37 -C)
38 cvsclean=t
40 -f)
41 force="-f"
43 -h)
44 usage
46 -V)
47 version
48 exit
50 -*)
51 echo >&2 "Parameter $1 is not known."
52 usage
55 break
57 esac
58 shift
59 done
61 if test $# = 0 ; then
62 usage
65 locate_git_repo
67 if test ! ".cvs" -o ! -d ".cvs/CVS/"
68 then
69 echo >&2 "CVS working directory not found."
70 die "Make sure you imported your CVS repository using gc-import."
73 if test "$cvsclean" = "t"
74 then
75 (cd ".cvs" && cvs up -C && find . -iname ".#*" -exec rm '{}' \;)
78 if test -d ".git" -a -d ".cvs"
79 then
80 cd ".cvs"
81 GIT_DIR="../.git" git-cvsexportcommit -v $force $commit -u $1
82 else
83 if test ! -d ".git"
84 then
85 die "Not a git repository"
88 if test ! -d ".cvs"
89 then
90 echo >&2 "No cvs repository found in .cvs. "
91 die "Make sure you follow the standards"