Fix the short description
[gc-utils.git] / gc-multi-commit.sh
blob9d8b8f34f5c05c922ba72cc9daf159bb47592422
1 #!/bin/sh
2 VERSION="$VERSION$"
3 PROGNAME="$PROGNAME$"
5 check_git ()
8 git --version > /dev/null
10 if test $? != 0
11 then
12 echo >&2 "Git not found. It's either not installed or not in \$PATH"
13 exit 127
16 version=`git --version | grep -o "[12]\.[5-9]\.[0-9]"`
17 if test -z "$version"
18 then
19 echo "Wrong git version. $prog needs git 1.5.0 or higher, but "`git --version`" found."
20 exit 127
24 usage ()
26 echo "Usage:" `basename $0`" [OPTIONS] <sha1>"
27 echo "Options are:"
28 echo " -h show help"
29 echo " -v verbosity"
30 echo " -a commit all differences without being asked"
31 echo " WARNING: use this option with caution"
32 echo " -V show version information"
33 echo
34 exit 127
37 version ()
39 echo "$PROGNAME: "`basename $0`-$VERSION
42 selecting ()
44 RESULT=""
45 while true
47 i=1
48 for word in $WORDS
50 echo "${i}) $word"
51 i=`expr $i + 1`
52 done
53 echo -n "Select> "
54 read select
55 if test $i -gt $select
56 then
57 break
59 done
60 i=1
61 for word in $WORDS
63 if test $i -eq $select
64 then
65 RESULT=$word
66 break
68 i=`expr $i + 1`
69 done
72 help ()
74 echo "Interactive git to cvs commiter"
75 echo
76 echo "Please use CTR+<RETURN> in the menu select prompt"
77 echo
80 cont ()
82 while true
84 echo -n "Sure? [yn] "
85 read in
86 if test "$in" = "n"
87 then
88 return 1
90 if test "$in" = "y"
91 then
92 return 0
94 done
97 check_git
99 verbose=
100 while test $# != 0
102 case "$1" in
104 usage
107 version
108 exit
111 verbose="-v"
114 git-cherry origin | sed -n 's/^+ //p' | xargs -l1 gc-commit -c
115 exit
117 esac
118 shift
119 done
121 git-branch 2>/dev/null
122 if test $? -ne 0
123 then
124 echo >&2 "not a repository"
125 exit 127
128 while true
130 echo ""
132 WORDS="`git cherry origin | egrep -o -e "[a-f0-9]{40}.*"` exit help"; selecting; sha=$RESULT
133 if test -z "$sha"
134 then
135 echo >&2 "not found"
136 exit 127
138 if test "$sha" = "exit"
139 then
140 exit
142 if test "$sha" = "help"
143 then
144 help
145 else
146 WORDS="log diff commit abort"; selecting; action=$RESULT
147 if test "$action" = "log"
148 then
149 git-log -n 1 $sha
150 elif test "$action" = "diff"
151 then
152 git diff $sha
153 elif test "$action" = "commit"
154 then
155 cont
156 if test $? -eq 0
157 then
158 gc-commit $sha
162 done