* [PATCH v2] bisect: fix bad rev checking in "git bisect good"
@ 2008-04-12 7:03 Christian Couder
2008-04-12 9:17 ` Re* " Junio C Hamano
0 siblings, 1 reply; 2+ messages in thread
From: Christian Couder @ 2008-04-12 7:03 UTC (permalink / raw)
To: Junio Hamano, Ingo Molnar; +Cc: git
It seems that "git bisect good" and "git bisect skip" have never
properly checked arguments that have been passed to them. As soon
as one of them can be parsed as a SHA1, no error or warning would
be given.
This is because 'git rev-parse --revs-only --no-flags "$@"' always
"exit 0" and outputs all the SHA1 it can found from parsing "$@".
This patch fix this by using, for each "bisect good" argument, the
same logic as for the "bisect bad" argument.
While at it, this patch teaches "bisect bad" to give a meaningfull
error message when it is passed more than one argument.
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
git-bisect.sh | 18 +++++++-----------
t/t6030-bisect-porcelain.sh | 13 +++++++++++++
2 files changed, 20 insertions(+), 11 deletions(-)
This new version should give a better error message
than the previous one.
diff --git a/git-bisect.sh b/git-bisect.sh
index a1343f6..408775a 100755
--- a/git-bisect.sh
+++ b/git-bisect.sh
@@ -155,20 +155,16 @@ bisect_state() {
rev=$(git rev-parse --verify HEAD) ||
die "Bad rev input: HEAD"
bisect_write "$state" "$rev" ;;
- 2,bad)
- rev=$(git rev-parse --verify "$2^{commit}") ||
- die "Bad rev input: $2"
- bisect_write "$state" "$rev" ;;
- *,good|*,skip)
+ 2,bad|*,good|*,skip)
shift
- revs=$(git rev-parse --revs-only --no-flags "$@") &&
- test '' != "$revs" || die "Bad rev input: $@"
- for rev in $revs
+ for rev in "$@"
do
- rev=$(git rev-parse --verify "$rev^{commit}") ||
- die "Bad rev commit: $rev^{commit}"
- bisect_write "$state" "$rev"
+ sha=$(git rev-parse --verify "$rev^{commit}") ||
+ die "Bad rev input: $rev"
+ bisect_write "$state" "$sha"
done ;;
+ *,bad)
+ die "'git bisect bad' can take only one argument." ;;
*)
usage ;;
esac
diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh
index f471c15..32d6118 100755
--- a/t/t6030-bisect-porcelain.sh
+++ b/t/t6030-bisect-porcelain.sh
@@ -71,6 +71,19 @@ test_expect_success 'bisect start with one bad and good' '
git bisect next
'
+test_expect_success 'bisect good and bad fails if not given only revs' '
+ git bisect reset &&
+ git bisect start &&
+ test_must_fail git bisect good foo $HASH1 &&
+ test_must_fail git bisect good $HASH1 bar &&
+ test_must_fail git bisect bad frotz &&
+ test_must_fail git bisect bad $HASH3 $HASH4 &&
+ test_must_fail git bisect skip bar $HASH3 &&
+ test_must_fail git bisect skip $HASH1 foo &&
+ git bisect good $HASH1 &&
+ git bisect bad $HASH4
+'
+
test_expect_success 'bisect reset: back in the master branch' '
git bisect reset &&
echo "* master" > branch.expect &&
--
1.5.5.46.gb6f72.dirty
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re* [PATCH v2] bisect: fix bad rev checking in "git bisect good"
2008-04-12 7:03 [PATCH v2] bisect: fix bad rev checking in "git bisect good" Christian Couder
@ 2008-04-12 9:17 ` Junio C Hamano
0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2008-04-12 9:17 UTC (permalink / raw)
To: Christian Couder; +Cc: Ingo Molnar, git
I've applied your earlier one to maint and propagated it all the way up,
and pushed the results out for tonight. I'll apply the following as a
follow-up patch later on top of what I've already pushed out, which is the
difference between the one applied and your v2.
-- >8 --
bisect: report bad rev better
The previous one overwrote the variable used to report the bad input
when the input is actually bad, and we did not give a useful enough
information. This corrects it.
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
git-bisect.sh | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/git-bisect.sh b/git-bisect.sh
index c8be9f7..c99ffee 100755
--- a/git-bisect.sh
+++ b/git-bisect.sh
@@ -155,9 +155,9 @@ bisect_state() {
shift
for rev in "$@"
do
- rev=$(git rev-parse --verify "$rev^{commit}") ||
+ sha=$(git rev-parse --verify "$rev^{commit}") ||
die "Bad rev input: $rev"
- bisect_write "$state" "$rev"
+ bisect_write "$state" "$sha"
done ;;
*,bad)
die "'git bisect bad' can take only one argument." ;;
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-04-12 9:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-12 7:03 [PATCH v2] bisect: fix bad rev checking in "git bisect good" Christian Couder
2008-04-12 9:17 ` Re* " 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).