bisect: quote pathnames for eval safety.
... and make sure they are on the same line. Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Nov 27, 2005 at 17:42 UTC
e9a45d75b5eccfc288c4533b5e34af1f77dd32c9
1 file changed
+20
-5
git-bisect.sh
+20
-5
@@ -1,9 +1,19 @@
1
#!/bin/sh
2
. git-sh-setup
3
4
+sq() {
5
+ perl -e '
6
+ for (@ARGV) {
7
+ s/'\''/'\'\\\\\'\''/g;
8
+ print " '\''$_'\''";
9
+ }
10
+ print "\n";
11
+ ' "$@"
12
+}
13
+
14
usage() {
15
echo >&2 'usage: git bisect [start|bad|good|next|reset|visualize]
6
-git bisect start reset bisect state and start bisection.
16
+git bisect start [<pathspec>] reset bisect state and start bisection.
17
git bisect bad [<rev>] mark <rev> a known-bad revision.
18
git bisect good [<rev>...] mark <rev>... known-good revisions.
19
git bisect next find next bisection to test and check it out.
@@ -56,8 +66,11 @@ bisect_start() {
66
rm -f "$GIT_DIR/refs/heads/bisect"
67
rm -rf "$GIT_DIR/refs/bisect/"
68
mkdir "$GIT_DIR/refs/bisect"
59
- echo "git-bisect start $@" >"$GIT_DIR/BISECT_LOG"
60
- echo "$@" > "$GIT_DIR/BISECT_NAMES"
69
+ {
70
+ echo -n "git-bisect start"
71
+ sq "$@"
72
+ } >"$GIT_DIR/BISECT_LOG"
73
+ sq "$@" >"$GIT_DIR/BISECT_NAMES"
74
}
75
76
bisect_bad() {
@@ -142,7 +155,8 @@ bisect_next() {
155
156
bisect_visualize() {
157
bisect_next_check fail
145
- gitk bisect/bad --not `cd "$GIT_DIR/refs" && echo bisect/good-*` -- $(cat $GIT_DIR/BISECT_NAMES)
158
+ not=`cd "$GIT_DIR/refs" && echo bisect/good-*`
159
+ eval gitk bisect/bad --not $not -- $(cat "$GIT_DIR/BISECT_NAMES")
160
}
161
162
bisect_reset() {
@@ -173,7 +187,8 @@ bisect_replay () {
187
test "$bisect" = "git-bisect" || continue
188
case "$command" in
189
start)
176
- bisect_start
190
+ cmd="bisect_start $rev"
191
+ eval "$cmd"
192
;;
193
good)
194
echo "$rev" >"$GIT_DIR/refs/bisect/good-$rev"