Fix double quotes in a string comparision
[gc-utils.git] / gc-multi-commit.sh
blob658c36cc0a24a250cb88520d32fcf96cb34ae05e
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 description
53 i=`expr $i + 1`
54 done
55 echo -n "Select> "
56 read select
57 if test $i -gt $select
58 then
59 break
61 done
62 i=1
63 for word in $WORDS
65 if test $i -eq $select
66 then
67 RESULT=$word
68 break
70 i=`expr $i + 1`
71 done
74 description ()
76 echo $word | grep -E "[a-f0-9]{40}" >/dev/null
77 if test $? -eq 0
78 then
79 echo -n " "
80 git log -n 1 --pretty=format:"%s" $word
84 help ()
86 echo "Interactive git to cvs commiter"
87 echo
88 echo "Please use CTR+<RETURN> in the menu select prompt"
89 echo
92 cont ()
94 while true
96 echo -n "Sure? [yn] "
97 read in
98 if test "$in" = "n"
99 then
100 return 1
102 if test "$in" = "y"
103 then
104 return 0
106 done
109 check_git
111 verbose=
112 while test $# != 0
114 case "$1" in
116 usage
119 version
120 exit
123 verbose="-v"
126 git-cherry origin | sed -n 's/^+ //p' | xargs -l1 gc-commit -c
127 exit
129 esac
130 shift
131 done
133 git-branch 2>/dev/null
134 if test $? -ne 0
135 then
136 echo >&2 "not a repository"
137 exit 127
140 while true
142 echo ""
143 echo "Menu ---------------------------------------"
144 echo "Use CTRL+<RETURN>"
145 WORDS="`git cherry origin | grep -o -E "[0-9a-f]{40}"` exit help"; selecting; sha=$RESULT
146 if test -z "$sha"
147 then
148 echo >&2 "not found"
149 exit 127
151 if test "$sha" = "exit"
152 then
153 exit
155 if test "$sha" = "help"
156 then
157 help
158 else
159 while true
161 echo ""
162 WORDS="log diff commit abort"; selecting; action=$RESULT
163 if test "$action" = "log"
164 then
165 git log -n 1 $sha
166 elif test "$action" = "diff"
167 then
168 git show $sha
169 elif test "$action" = "commit"
170 then
171 cont
172 if test $? -eq 0
173 then
174 gc-commit -c $sha
176 elif test "$action" = "abort"
177 then
178 break
180 done
182 done