git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bisect: fix quoting TRIED revs when "bad" commit is also "skip"ped
@ 2009-02-26  7:29 Christian Couder
  2009-02-26  8:47 ` Junio C Hamano
  0 siblings, 1 reply; 6+ messages in thread
From: Christian Couder @ 2009-02-26  7:29 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Before this patch, when the "bad" commit was also "skip"ped and
when more than one commit was skipped, the "filter_skipped" function
would have printed something like:

bisect_rev=<hash1>|<hash2>

(where <hash1> and <hash2> are hexadecimal sha1 hashes)

and this would have been evaled later as piping "bisect_rev=<hash1>"
into "<hash2>", which would have failed.

So this patch makes the "filter_skipped" function properly quote
what it outputs, so that it will print something like:

bisect_rev="<hash1>|<hash2>"

which will be properly evaled later.

A test case is added to the test suite.

And while at it, we also remove a spurious space where the
"exit_if_skipped_commits" function is defined.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
 git-bisect.sh               |    4 ++--
 t/t6030-bisect-porcelain.sh |   25 +++++++++++++++++++++++++
 2 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/git-bisect.sh b/git-bisect.sh
index 85db4ba..105bc6a 100755
--- a/git-bisect.sh
+++ b/git-bisect.sh
@@ -309,7 +309,7 @@ filter_skipped() {
 			# This should happen only if the "bad"
 			# commit is also a "skip" commit.
 			,,*,bisect_rev*)
-				echo "bisect_rev=$TRIED"
+				echo "bisect_rev=\"$TRIED\""
 				VARS=1
 				;;
 
@@ -342,7 +342,7 @@ filter_skipped() {
 	done
 }
 
-exit_if_skipped_commits () {
+exit_if_skipped_commits() {
 	_tried=$1
 	if expr "$_tried" : ".*[|].*" > /dev/null ; then
 		echo "There are only 'skip'ped commit left to test."
diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh
index dd7eac8..b5da16f 100755
--- a/t/t6030-bisect-porcelain.sh
+++ b/t/t6030-bisect-porcelain.sh
@@ -224,6 +224,31 @@ test_expect_success 'bisect skip: cannot tell between 2 commits' '
 	fi
 '
 
+# $HASH1 is good, $HASH4 is both skipped and bad, we skip $HASH3
+# and $HASH2 is good,
+# so we should not be able to tell the first bad commit
+# among $HASH3 and $HASH4
+test_expect_success 'bisect skip: with commit both bad and skipped' '
+	git bisect start &&
+	git bisect skip &&
+	git bisect bad &&
+	git bisect good $HASH1 &&
+	git bisect skip &&
+	if git bisect good > my_bisect_log.txt
+	then
+		echo Oops, should have failed.
+		false
+	else
+		test $? -eq 2 &&
+		grep "first bad commit could be any of" my_bisect_log.txt &&
+		test_must_fail grep $HASH1 my_bisect_log.txt &&
+		test_must_fail grep $HASH2 my_bisect_log.txt &&
+		grep $HASH3 my_bisect_log.txt &&
+		grep $HASH4 my_bisect_log.txt &&
+		git bisect reset
+	fi
+'
+
 # We want to automatically find the commit that
 # introduced "Another" into hello.
 test_expect_success \
-- 
1.6.2.rc1.20.g8c5b.dirty

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-02-27 22:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-26  7:29 [PATCH] bisect: fix quoting TRIED revs when "bad" commit is also "skip"ped Christian Couder
2009-02-26  8:47 ` Junio C Hamano
2009-02-27  6:30   ` Christian Couder
2009-02-27  8:45     ` Junio C Hamano
2009-02-27 21:05       ` Christian Couder
2009-02-27 22:34         ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).