Thread (1 message) 1 message, 1 author, 2016-06-15
DORMANTno replies

[PATCH] bisect: quote pathnames for eval safety.

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:42:13
Subsystem: the rest · Maintainer: Linus Torvalds

Possibly related (same subject, not in this thread)

Linus Torvalds [off-list ref] writes:
Almost totally untested, and I guarantee that if your pathnames have 
spaces in them (or your GIT_DIR has spaces in it) this won't work. I don't 
know how to fix that, my shell programming isn't good enough.
Like this?  I've placed the bisect patch with this in the
proposed updates.

---

 git-bisect.sh |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)

applies-to: 7da44ab45773e0a424c1e08c838c1f6deeb6ceb2
82c8f5bed2ae61f1f368cfca84f6b0194b1ad208
diff --git a/git-bisect.sh b/git-bisect.sh
index 2455f00..d4196f9 100755
--- a/git-bisect.sh
+++ b/git-bisect.sh
@@ -1,9 +1,16 @@
 #!/bin/sh
 . git-sh-setup
 
+sq() {
+    for x
+    do
+	echo "$x" | sed -e "s/'/'\\\\''/g" -e "s/^/'/" -e "s/\$/'/"
+    done
+}
+
 usage() {
     echo >&2 'usage: git bisect [start|bad|good|next|reset|visualize]
-git bisect start		reset bisect state and start bisection.
+git bisect start [<pathspec>]	reset bisect state and start bisection.
 git bisect bad [<rev>]		mark <rev> a known-bad revision.
 git bisect good [<rev>...]	mark <rev>... known-good revisions.
 git bisect next			find next bisection to test and check it out.
@@ -56,8 +63,8 @@ bisect_start() {
 	rm -f "$GIT_DIR/refs/heads/bisect"
 	rm -rf "$GIT_DIR/refs/bisect/"
 	mkdir "$GIT_DIR/refs/bisect"
-	echo "git-bisect start $@" >"$GIT_DIR/BISECT_LOG"
-	echo "$@" > "$GIT_DIR/BISECT_NAMES"
+	sq git-bisect start "$@" >"$GIT_DIR/BISECT_LOG"
+	sq "$@" >"$GIT_DIR/BISECT_NAMES"
 }
 
 bisect_bad() {
@@ -142,7 +149,8 @@ bisect_next() {
 
 bisect_visualize() {
 	bisect_next_check fail
-	gitk bisect/bad --not `cd "$GIT_DIR/refs" && echo bisect/good-*` -- $(cat $GIT_DIR/BISECT_NAMES)
+	not=`cd "$GIT_DIR/refs" && echo bisect/good-*`
+	eval gitk bisect/bad --not $not -- $(cat "$GIT_DIR/BISECT_NAMES")
 }
 
 bisect_reset() {
---
0.99.9.GIT
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help