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
12 echo "Usage: "`basename $0`" [OPTIONS]"
16 echo " -m use merge strategy instead of rebasing"
17 echo " -cn do not update the cvs repository"
18 echo " -V show version information"
50 echo >&2 "Parameter $1 is not known."
60 if test ! ".cvs" -o ! -d ".cvs/CVS/"
62 echo >&2 "CVS working directory not found."
63 die
"Make sure you imported your CVS repository using gc-import."
66 branch
=`git branch | grep "^* " | cut -c 3-`
68 CVSROOT
=`cat .cvs/CVS/Root`
69 MODULE
=`cat .cvs/CVS/Repository`
71 echo "Repository: $CVSROOT"
72 echo "Module: $MODULE"
73 echo "GIT Branch: $branch"
76 # first stash away our local changes
77 echo "Stashing local changes"
78 test -n "$verbose" && git stash save
"stashed by gcutils"
79 test -z "$verbose" && git stash save
"stashed by gcutils" 2>/dev
/null
1>/dev
/null
84 remote
=`git-config gc-utils.remote`
88 refspec
="refs/remotes/$remote/master"
91 refspec
="refs/heads/origin"
95 # if -m is not specified we do a rebase instead of a merge
96 # therefore git cvsimport will be called -i ($do_rebase)
97 git-cvsimport
$remote $do_rebase $verbose -a -m -k -d $CVSROOT "$MODULE"
99 if test -n "$do_rebase"
101 # we actually did not yet merged back into master but we try to rebase
102 git-rebase
`git show-ref -s $refspec` master
106 echo "Rebasing failed."
107 echo "Please use rebase to rebase the origin branch or use merge to"
108 echo "do a merge instead. Notice that merge might result in duplicated commits"
110 echo "gc utils aborted the rebase"
112 git-checkout
$branch 1>/dev
/null
2>/dev
/null
114 # reapply our stashed dirty changes
116 echo "Reapplying local changes"
118 test -n "$verbose" && git-stash pop
119 test -z "$verbose" && git-stash pop
2>/dev
/null
1>/dev
/null
125 git-checkout
$branch 1>/dev
/null
2>/dev
/null
127 # reapply our stashed dirty changes
129 echo "Reapplying local changes"
130 test -n "$verbose" && git-stash pop
131 test -z "$verbose" && git-stash pop
2>/dev
/null
1>/dev
/null
133 if test -n "$cvsupdate"
135 echo "Running cvs update"
137 cvs
$quiet update
-d -P