* [PATCH] Bisect run: "skip" current commit if script exit code is 125.
@ 2007-10-26 3:39 Christian Couder
2007-10-26 6:25 ` Benoit SIGOURE
0 siblings, 1 reply; 5+ messages in thread
From: Christian Couder @ 2007-10-26 3:39 UTC (permalink / raw)
To: Junio Hamano, Shawn O. Pearce, Johannes Schindelin; +Cc: git
This is incompatible with previous versions because an exit code
of 125 used to mark current commit as "bad". But hopefully this exit
code is not much used by test scripts or other programs. (126 and 127
are used by bash.)
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
Documentation/git-bisect.txt | 8 ++++++--
git-bisect.sh | 11 ++++++++++-
t/t6030-bisect-porcelain.sh | 40 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 56 insertions(+), 3 deletions(-)
diff --git a/Documentation/git-bisect.txt b/Documentation/git-bisect.txt
index 785f381..14b7a95 100644
--- a/Documentation/git-bisect.txt
+++ b/Documentation/git-bisect.txt
@@ -183,13 +183,17 @@ $ git bisect run my_script
Note that the "run" script (`my_script` in the above example) should
exit with code 0 in case the current source code is good and with a
-code between 1 and 127 (included) in case the current source code is
-bad.
+code between 1 and 127 (included), except 125 that is special, in case
+the current source code is bad.
Any other exit code will abort the automatic bisect process. (A
program that does "exit(-1)" leaves $? = 255, see exit(3) manual page,
the value is chopped with "& 0377".)
+The special exit code 125 should be used when the current source code
+cannot be tested. If the "run" script exits with this code, the current
+revision will be "skip"ped, see `git bisect skip` above.
+
You may often find that during bisect you want to have near-constant
tweaks (e.g., s/#define DEBUG 0/#define DEBUG 1/ in a header file, or
"revision that does not have this commit needs this patch applied to
diff --git a/git-bisect.sh b/git-bisect.sh
index f8d0099..180c6c2 100755
--- a/git-bisect.sh
+++ b/git-bisect.sh
@@ -392,7 +392,10 @@ bisect_run () {
fi
# Find current state depending on run success or failure.
- if [ $res -gt 0 ]; then
+ # A special exit code of 125 means cannot test.
+ if [ $res -eq 125 ]; then
+ state='skip'
+ elif [ $res -gt 0 ]; then
state='bad'
else
state='good'
@@ -404,6 +407,12 @@ bisect_run () {
cat "$GIT_DIR/BISECT_RUN"
+ if grep "first bad commit could be any of" "$GIT_DIR/BISECT_RUN" \
+ > /dev/null; then
+ echo >&2 "bisect run cannot continue any more"
+ exit $res
+ fi
+
if [ $res -ne 0 ]; then
echo >&2 "bisect run failed:"
echo >&2 "'bisect_state $state' exited with error code $res"
diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh
index 16d0c4a..53956c0 100755
--- a/t/t6030-bisect-porcelain.sh
+++ b/t/t6030-bisect-porcelain.sh
@@ -177,6 +177,46 @@ test_expect_success 'bisect skip and bisect replay' '
git bisect reset
'
+HASH6=
+test_expect_success 'bisect run & skip: cannot tell between 2' '
+ add_line_into_file "6: Yet a line." hello &&
+ HASH6=$(git rev-parse --verify HEAD) &&
+ echo "#"\!"/bin/sh" > test_script.sh &&
+ echo "tail -1 hello | grep Ciao > /dev/null && exit 125" >> test_script.sh &&
+ echo "grep line hello > /dev/null" >> test_script.sh &&
+ echo "test \$? -ne 0" >> test_script.sh &&
+ chmod +x test_script.sh &&
+ git bisect start $HASH6 $HASH1 &&
+ if git bisect run ./test_script.sh > 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 &&
+ ! grep $HASH3 my_bisect_log.txt &&
+ ! grep $HASH6 my_bisect_log.txt &&
+ grep $HASH4 my_bisect_log.txt &&
+ grep $HASH5 my_bisect_log.txt
+ fi
+'
+
+HASH7=
+test_expect_success 'bisect run & skip: find first bad' '
+ git bisect reset &&
+ add_line_into_file "7: Should be the last line." hello &&
+ HASH7=$(git rev-parse --verify HEAD) &&
+ echo "#"\!"/bin/sh" > test_script.sh &&
+ echo "tail -1 hello | grep Ciao > /dev/null && exit 125" >> test_script.sh &&
+ echo "tail -1 hello | grep day > /dev/null && exit 125" >> test_script.sh &&
+ echo "grep Yet hello > /dev/null" >> test_script.sh &&
+ echo "test \$? -ne 0" >> test_script.sh &&
+ chmod +x test_script.sh &&
+ git bisect start $HASH7 $HASH1 &&
+ git bisect run ./test_script.sh > my_bisect_log.txt &&
+ grep "$HASH6 is first bad commit" my_bisect_log.txt
+'
+
#
#
test_done
--
1.5.3.4.1494.g253d
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] Bisect run: "skip" current commit if script exit code is 125.
2007-10-26 3:39 [PATCH] Bisect run: "skip" current commit if script exit code is 125 Christian Couder
@ 2007-10-26 6:25 ` Benoit SIGOURE
2007-10-27 5:02 ` Christian Couder
0 siblings, 1 reply; 5+ messages in thread
From: Benoit SIGOURE @ 2007-10-26 6:25 UTC (permalink / raw)
To: Christian Couder; +Cc: git list
[-- Attachment #1: Type: text/plain, Size: 1980 bytes --]
On Oct 26, 2007, at 5:39 AM, Christian Couder wrote:
> This is incompatible with previous versions because an exit code
> of 125 used to mark current commit as "bad". But hopefully this exit
> code is not much used by test scripts or other programs. (126 and 127
> are used by bash.)
>
> Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
> ---
> Documentation/git-bisect.txt | 8 ++++++--
> git-bisect.sh | 11 ++++++++++-
> t/t6030-bisect-porcelain.sh | 40 +++++++++++++++++++++++++++++++
> +++++++++
> 3 files changed, 56 insertions(+), 3 deletions(-)
>
> diff --git a/Documentation/git-bisect.txt b/Documentation/git-
> bisect.txt
> index 785f381..14b7a95 100644
> --- a/Documentation/git-bisect.txt
> +++ b/Documentation/git-bisect.txt
> @@ -183,13 +183,17 @@ $ git bisect run my_script
>
> Note that the "run" script (`my_script` in the above example) should
> exit with code 0 in case the current source code is good and with a
> -code between 1 and 127 (included) in case the current source code is
> -bad.
> +code between 1 and 127 (included), except 125 that is special, in
> case
> +the current source code is bad.
>
> Any other exit code will abort the automatic bisect process. (A
> program that does "exit(-1)" leaves $? = 255, see exit(3) manual
> page,
> the value is chopped with "& 0377".)
>
> +The special exit code 125 should be used when the current source code
> +cannot be tested. If the "run" script exits with this code, the
> current
> +revision will be "skip"ped, see `git bisect skip` above.
> +
> You may often find that during bisect you want to have near-constant
> tweaks (e.g., s/#define DEBUG 0/#define DEBUG 1/ in a header file, or
> "revision that does not have this commit needs this patch applied to
Since exit 77 is already used by automake to mean "skip", wouldn't it
be better to do the same thing here?
Cheers,
--
Benoit Sigoure aka Tsuna
EPITA Research and Development Laboratory
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 186 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Bisect run: "skip" current commit if script exit code is 125.
2007-10-26 6:25 ` Benoit SIGOURE
@ 2007-10-27 5:02 ` Christian Couder
[not found] ` <20071027052834.GA3115@hermes.priv>
0 siblings, 1 reply; 5+ messages in thread
From: Christian Couder @ 2007-10-27 5:02 UTC (permalink / raw)
To: Benoit SIGOURE; +Cc: git list
Le vendredi 26 octobre 2007, Benoit SIGOURE a écrit :
> On Oct 26, 2007, at 5:39 AM, Christian Couder wrote:
> >
> > +The special exit code 125 should be used when the current source code
> > +cannot be tested. If the "run" script exits with this code, the
> > current
> > +revision will be "skip"ped, see `git bisect skip` above.
> > [...]
>
> Since exit 77 is already used by automake to mean "skip", wouldn't it
> be better to do the same thing here?
I don't think 77 is better, first because for automake this is to ignore
some non portable test results "in environments where they don't make
sense", so if we "bisect run" the same test script and it returns 77 once,
it will probably returns 77 everytime because the environment will not have
changed after a new revision has been checked out.
Also there is:
$ grep 77 /usr/include/sysexits.h
#define EX_NOPERM 77 /* permission denied */
and a search for "include <sysexits.h>" in http://www.google.com/codesearch
returns a lot of results.
Christian.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Bisect run: "skip" current commit if script exit code is 125.
[not found] ` <20071027052834.GA3115@hermes.priv>
@ 2007-10-27 5:33 ` Tom Prince
2007-10-27 6:12 ` Junio C Hamano
0 siblings, 1 reply; 5+ messages in thread
From: Tom Prince @ 2007-10-27 5:33 UTC (permalink / raw)
To: git
On Sat, Oct 27, 2007 at 07:02:31AM +0200, Christian Couder wrote:
> Le vendredi 26 octobre 2007, Benoit SIGOURE a écrit :
> > On Oct 26, 2007, at 5:39 AM, Christian Couder wrote:
> > >
> > > +The special exit code 125 should be used when the current source code
> > > +cannot be tested. If the "run" script exits with this code, the
> > > current
> > > +revision will be "skip"ped, see `git bisect skip` above.
> > > [...]
> >
> Also there is:
>
> $ grep 77 /usr/include/sysexits.h
> #define EX_NOPERM 77 /* permission denied */
How about
#define EX_TEMPFAIL 75 /* temp failure; user is invited to retry */
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Bisect run: "skip" current commit if script exit code is 125.
2007-10-27 5:33 ` Tom Prince
@ 2007-10-27 6:12 ` Junio C Hamano
0 siblings, 0 replies; 5+ messages in thread
From: Junio C Hamano @ 2007-10-27 6:12 UTC (permalink / raw)
To: Tom Prince; +Cc: git
Tom Prince <tom.prince@ualberta.net> writes:
> On Sat, Oct 27, 2007 at 07:02:31AM +0200, Christian Couder wrote:
>> Le vendredi 26 octobre 2007, Benoit SIGOURE a écrit :
>> > On Oct 26, 2007, at 5:39 AM, Christian Couder wrote:
>> > >
>> > > +The special exit code 125 should be used when the current source code
>> > > +cannot be tested. If the "run" script exits with this code, the
>> > > current
>> > > +revision will be "skip"ped, see `git bisect skip` above.
>> > > [...]
>> >
>> Also there is:
>>
>> $ grep 77 /usr/include/sysexits.h
>> #define EX_NOPERM 77 /* permission denied */
>
> How about
>
> #define EX_TEMPFAIL 75 /* temp failure; user is invited to retry */
Let's stop bikeshedding. 125 is as good as anything else.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2007-10-27 6:12 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-26 3:39 [PATCH] Bisect run: "skip" current commit if script exit code is 125 Christian Couder
2007-10-26 6:25 ` Benoit SIGOURE
2007-10-27 5:02 ` Christian Couder
[not found] ` <20071027052834.GA3115@hermes.priv>
2007-10-27 5:33 ` Tom Prince
2007-10-27 6:12 ` 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).