From: Junio C Hamano Date: Mon, 28 Nov 2005 01:51:23 GMT Subject: [PATCH] bisect: quote pathnames for eval safety. Message-ID: <7vmzjp35gk.fsf_-_@assigned-by-dhcp.cox.net> In-Reply-To: Linus Torvalds 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 [] reset bisect state and start bisection. git bisect bad [] mark a known-bad revision. git bisect good [...] mark ... 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