Rebase only the master and save the current branch to go back to it after rebasing
[gc-utils.git] / gc-import.sh
blob6a63af9ee77cab087cdf2e0eed6a0a95101915b8
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 VERSION="$VERSION$"
9 PROGNAME="$PROGNAME$"
11 check_git ()
14 git --version > /dev/null
16 if test $? != 0
17 then
18 echo >&2 "Git not found. It's either not installed or not in \$PATH"
19 exit 127
22 version=`git --version | grep -o "[12]\.[5-9]\.[0-9]"`
23 if test -z "$version"
24 then
25 echo "Wrong git version. $prog needs git 1.5.0 or higher, but "`git --version`" found."
26 exit 127
30 version ()
32 echo "$PROGNAME: "`basename $0`-$VERSION
35 usage ()
37 echo "Usage:" `basename $0` "[OPTIONS] <cvsroot> <module>"
38 echo "Options are:"
39 echo " -h show help"
40 echo " -v verbosity"
41 echo " -d <dir> directory for checkout"
42 echo " -gu convert underscores during gitimport"
43 echo " -u Do not write an ignore file"
44 echo " -V show version information"
45 echo
46 exit 127
49 check_git
51 verbose=
52 cvrtudsr=
53 dir=
54 quiet="-Q"
55 ignorefile="t"
56 while test $# != 0
57 do
58 case "$1" in
59 -u)
60 ignorefile=
62 -v)
63 verbose="-v"
64 quiet=
66 -d)
67 shift
68 dir="$1"
70 -gu)
71 cvrtudsr="-u"
73 -h)
74 usage
76 -V)
77 version
78 exit
80 -*)
81 echo >&2 "Parameter $1 is not known."
82 usage
85 break
87 esac
88 shift
89 done
91 CVSROOT=$1
92 MODULE=$2
94 if test $# != 2
95 then
96 usage
99 echo "Repository: $CVSROOT"
100 echo "Module: $MODULE"
101 echo
103 if test ${#dir} -eq 0
104 then
105 dir="$MODULE"
108 if test -d "$dir/.cvs"
109 then
110 echo "It seems that you are trying to use gc-import on an allready tracked repository."
111 echo "Please use gc-update instead"
112 exit 127
115 mkdir $dir
117 git-cvsimport -a -k $verbose $cvrtudsr -m -d$CVSROOT -C "$dir" $MODULE && cd "$dir" && echo "Initialize CVS repository in $PWD/.cvs" && cvs -d$CVSROOT $quiet -z 9 co -d ".cvs" $MODULE
119 if test $? != 0
120 then
121 echo >&2 "Failed."
122 exit 127
125 if test -n "$ignorefile"
126 then
127 if test ! -f ".gitignore"
128 then
129 echo ".cvs" > ".gitignore" && echo "Create ignore file in $PWD/.gitignore"
130 else
131 echo ".cvs" >> ".gitignore" && echo "Add ignore entry to $PWD/.gitignore"
135 cd $OLDPWD