git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] bisect: quote pathnames for eval safety.

From
Junio C Hamano <junkio@cox.net>
Date
Nov 28, 2005, 01:51 UTC
Message-ID
<7vmzjp35gk.fsf_-_@assigned-by-dhcp.cox.net>
In-Reply-To
<Pine.LNX.4.64.0511271106360.13959@g5.osdl.org>
Linus Torvalds <torvalds@osdl.org> 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
Previous: Junio C HamanoNext: Junio C Hamano
Message 6 of 8 in “Repository format version check series.”
  1. 0/4 Repository format version check series.Junio C Hamano, Nov 26, 2005
  2. What's in master and pu (aka when will 1.0rc4 be out)Junio C Hamano, Nov 27, 2005
  3. Timo HirvonenNov 27, 2005
  4. Linus TorvaldsNov 27, 2005
  5. Junio C HamanoNov 27, 2005
  6. bisect: quote pathnames for eval safety.Junio C Hamano, Nov 28, 2005
  7. Junio C HamanoNov 28, 2005
  8. Martin AtukundaNov 29, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.