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
13 git
--version > /dev
/null
17 echo >&2 "Git not found. It's either not installed or not in \$PATH"
21 version
=`git --version | grep -o "[12]\.[5-9]\.[0-9]"`
24 echo "Wrong git version. $prog needs git 1.5.0 or higher, but "`git --version`" found."
31 echo "$PROGNAME: "`basename $0`-$VERSION
35 gitdir
=`git-rev-parse --git-dir 2> /dev/null`
36 if test "$gitdir" = ""
38 echo >&2 "Please use this command from a git working tree."
46 echo "Usage: "`basename $0`" [OPTIONS]"
50 echo " -m use merge strategy instead of rebasing"
51 echo " -cn do not update the cvs repository"
52 echo " -V show version information"
84 echo >&2 "Parameter $1 is not known."
94 branch
=`git branch | grep "^* " | cut -c 3-`
96 if test ! ".cvs" -o ! -d ".cvs/CVS/"
98 echo >&2 "Cannot found .cvs directory"
102 CVSROOT
=`cat .cvs/CVS/Root`
103 MODULE
=`cat .cvs/CVS/Repository`
105 echo "Repository: $CVSROOT"
106 echo "Module: $MODULE"
107 echo "GIT Branch: $branch"
110 # first stash away our local changes
111 echo "Stashing local changes"
112 git stash save
"stashed by gcutils"
115 # if -m is not specified we do a rebase instead of a merge
116 # therefore git cvsimport will be called -i ($do_rebase)
117 git-cvsimport
$do_rebase $verbose -a -m -k -d $CVSROOT "$MODULE"
119 if test -n "$do_rebase"
121 # we actually did not yet merged back into master but we try to rebase
122 git-rebase origin master
126 echo "Rebasing failed."
127 echo "Please use rebase to rebase the origin branch or use merge to"
128 echo "do a merge instead. Notice that merge might result in duplicated commits"
130 echo "gc utils aborted the rebase"
132 git-checkout
$branch 1>/dev
/null
2>/dev
/null
134 # reapply our stashed dirty changes
136 echo "Reapplying local changes"
138 test -n "$verbose" && git-stash pop
139 test -z "$verbose" && git-stash pop
2>/dev
/null
1>/dev
/null
144 git-checkout
$branch 1>/dev
/null
2>/dev
/null
146 # reapply our stashed dirty changes
148 echo "Reapplying local changes"
149 test -n "$verbose" && git-stash pop
150 test -z "$verbose" && git-stash pop
2>/dev
/null
1>/dev
/null
154 if test -n "$cvsupdate"