[PATCH] Making it easier to find which change introduced a bug
This adds a new "git bisect" command.
- "git bisect start"
start bisection search.
- "git bisect bad <rev>"
mark some version known-bad (if no arguments, then current HEAD)
- "git bisect good <revs>..."
mark some versions known-good (if no arguments, then current HEAD)
- "git bisect reset <branch>"
done with bisection search and go back to your work (if
no arguments, then "master").
The way you use it is:
git bisect start
git bisect bad # Current version is bad
git bisect good v2.6.13-rc2 # v2.6.13-rc2 was the last version
# tested that was good
When you give at least one bad and one good versions, it will
bisect the revision tree and say something like:
Bisecting: 675 revisions left to test after this
and check out the state in the middle. Now, compile that kernel, and boot
it. Now, let's say that this booted kernel works fine, then just do
git bisect good # this one is good
which will now say
Bisecting: 337 revisions left to test after this
and you continue along, compiling that one, testing it, and depending on
whether it is good or bad, you say "git bisect good" or "git bisect bad",
and ask for the next bisection.
Until you have no more left, and you'll have been left with the first bad
kernel rev in "refs/bisect/bad".
Oh, and then after you want to reset to the original head, do a
git bisect reset
to get back to the master branch, instead of being in one of the bisection
branches ("git bisect start" will do that for you too, actually: it will
reset the bisection state, and before it does that it checks that you're
not using some old bisection branch).
Not really any harder than doing series of "quilt push" and "quilt pop",
now is it?
[jc: This patch is a rework based on what Linus posted to the
list. The changes are:
- The original introduced four separate commands, which was
three too many, so I merged them into one with subcommands.
- Since the next thing you would want to do after telling it
"bad" and "good" is always to bisect, this version does it
automatically for you.
- I think the termination condition was wrong. The original
version checked if the set of revisions reachable from next
bisection but not rechable from any of the known good ones
is empty, but if the current bisection was a bad one, this
would not terminate, so I changed it to terminate it when
the set becomes a singleton or empty.
- Removed the use of shell array variable.
]
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-07-30 17:08:20 +00:00
|
|
|
#!/bin/sh
|
2005-12-11 09:55:49 +00:00
|
|
|
|
2017-11-12 09:30:38 +00:00
|
|
|
USAGE='[help|start|bad|good|new|old|terms|skip|next|reset|visualize|view|replay|log|run]'
|
2008-04-11 03:55:21 +00:00
|
|
|
LONG_USAGE='git bisect help
|
2011-08-05 11:31:30 +00:00
|
|
|
print this long help message.
|
2020-08-28 15:31:19 +00:00
|
|
|
git bisect start [--term-{new,bad}=<term> --term-{old,good}=<term>]
|
2020-08-22 20:32:03 +00:00
|
|
|
[--no-checkout] [--first-parent] [<bad> [<good>...]] [--] [<pathspec>...]
|
2011-08-05 11:31:30 +00:00
|
|
|
reset bisect state and start bisection.
|
2015-06-29 15:40:33 +00:00
|
|
|
git bisect (bad|new) [<rev>]
|
|
|
|
mark <rev> a known-bad revision/
|
|
|
|
a revision after change in a given property.
|
|
|
|
git bisect (good|old) [<rev>...]
|
|
|
|
mark <rev>... known-good revisions/
|
|
|
|
revisions before change in a given property.
|
2015-06-29 15:40:34 +00:00
|
|
|
git bisect terms [--term-good | --term-bad]
|
|
|
|
show the terms used for old and new commits (default: bad, good)
|
2008-12-02 13:53:51 +00:00
|
|
|
git bisect skip [(<rev>|<range>)...]
|
2011-08-05 11:31:30 +00:00
|
|
|
mark <rev>... untestable revisions.
|
2007-04-04 05:12:02 +00:00
|
|
|
git bisect next
|
2011-08-05 11:31:30 +00:00
|
|
|
find next bisection to test and check it out.
|
2009-10-13 21:02:24 +00:00
|
|
|
git bisect reset [<commit>]
|
2011-08-05 11:31:30 +00:00
|
|
|
finish bisection search and go back to commit.
|
2017-11-12 09:30:38 +00:00
|
|
|
git bisect (visualize|view)
|
2011-08-05 11:31:30 +00:00
|
|
|
show bisect status in gitk.
|
2007-04-04 05:12:02 +00:00
|
|
|
git bisect replay <logfile>
|
2011-08-05 11:31:30 +00:00
|
|
|
replay bisection log.
|
2007-04-04 05:12:02 +00:00
|
|
|
git bisect log
|
2011-08-05 11:31:30 +00:00
|
|
|
show bisect log.
|
2007-04-04 05:12:02 +00:00
|
|
|
git bisect run <cmd>...
|
2011-08-05 11:31:30 +00:00
|
|
|
use <cmd>... to automatically bisect.
|
2008-04-11 03:55:21 +00:00
|
|
|
|
|
|
|
Please use "git help bisect" to get the full man page.'
|
2005-12-11 09:55:49 +00:00
|
|
|
|
2007-11-06 09:50:02 +00:00
|
|
|
OPTIONS_SPEC=
|
2005-11-24 08:12:11 +00:00
|
|
|
. git-sh-setup
|
[PATCH] Making it easier to find which change introduced a bug
This adds a new "git bisect" command.
- "git bisect start"
start bisection search.
- "git bisect bad <rev>"
mark some version known-bad (if no arguments, then current HEAD)
- "git bisect good <revs>..."
mark some versions known-good (if no arguments, then current HEAD)
- "git bisect reset <branch>"
done with bisection search and go back to your work (if
no arguments, then "master").
The way you use it is:
git bisect start
git bisect bad # Current version is bad
git bisect good v2.6.13-rc2 # v2.6.13-rc2 was the last version
# tested that was good
When you give at least one bad and one good versions, it will
bisect the revision tree and say something like:
Bisecting: 675 revisions left to test after this
and check out the state in the middle. Now, compile that kernel, and boot
it. Now, let's say that this booted kernel works fine, then just do
git bisect good # this one is good
which will now say
Bisecting: 337 revisions left to test after this
and you continue along, compiling that one, testing it, and depending on
whether it is good or bad, you say "git bisect good" or "git bisect bad",
and ask for the next bisection.
Until you have no more left, and you'll have been left with the first bad
kernel rev in "refs/bisect/bad".
Oh, and then after you want to reset to the original head, do a
git bisect reset
to get back to the master branch, instead of being in one of the bisection
branches ("git bisect start" will do that for you too, actually: it will
reset the bisection state, and before it does that it checks that you're
not using some old bisection branch).
Not really any harder than doing series of "quilt push" and "quilt pop",
now is it?
[jc: This patch is a rework based on what Linus posted to the
list. The changes are:
- The original introduced four separate commands, which was
three too many, so I merged them into one with subcommands.
- Since the next thing you would want to do after telling it
"bad" and "good" is always to bisect, this version does it
automatically for you.
- I think the termination condition was wrong. The original
version checked if the set of revisions reachable from next
bisection but not rechable from any of the known good ones
is empty, but if the current bisection was a bad one, this
would not terminate, so I changed it to terminate it when
the set becomes a singleton or empty.
- Removed the use of shell array variable.
]
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-07-30 17:08:20 +00:00
|
|
|
|
2008-02-10 13:59:50 +00:00
|
|
|
_x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
|
|
|
|
_x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
|
2015-06-29 15:40:29 +00:00
|
|
|
TERM_BAD=bad
|
|
|
|
TERM_GOOD=good
|
2008-02-10 13:59:50 +00:00
|
|
|
|
2005-08-30 19:45:41 +00:00
|
|
|
bisect_visualize() {
|
2019-01-02 15:38:34 +00:00
|
|
|
git bisect--helper --bisect-next-check $TERM_GOOD $TERM_BAD fail || exit
|
2007-12-07 10:25:34 +00:00
|
|
|
|
|
|
|
if test $# = 0
|
|
|
|
then
|
2011-03-21 13:14:22 +00:00
|
|
|
if test -n "${DISPLAY+set}${SESSIONNAME+set}${MSYSTEM+set}${SECURITYSESSIONID+set}" &&
|
2011-08-05 17:09:23 +00:00
|
|
|
type gitk >/dev/null 2>&1
|
2011-08-05 11:31:31 +00:00
|
|
|
then
|
2011-03-21 13:14:22 +00:00
|
|
|
set gitk
|
|
|
|
else
|
|
|
|
set git log
|
|
|
|
fi
|
2007-12-07 10:25:34 +00:00
|
|
|
else
|
|
|
|
case "$1" in
|
|
|
|
git*|tig) ;;
|
|
|
|
-*) set git log "$@" ;;
|
|
|
|
*) set git "$@" ;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
2009-11-23 04:16:14 +00:00
|
|
|
eval '"$@"' --bisect -- $(cat "$GIT_DIR/BISECT_NAMES")
|
2005-08-30 19:45:41 +00:00
|
|
|
}
|
|
|
|
|
2007-03-23 07:49:59 +00:00
|
|
|
bisect_run () {
|
2019-01-02 15:38:34 +00:00
|
|
|
git bisect--helper --bisect-next-check $TERM_GOOD $TERM_BAD fail || exit
|
2011-08-05 11:31:30 +00:00
|
|
|
|
2017-11-12 20:55:33 +00:00
|
|
|
test -n "$*" || die "$(gettext "bisect run failed: no command provided.")"
|
|
|
|
|
2011-08-05 11:31:30 +00:00
|
|
|
while true
|
|
|
|
do
|
|
|
|
command="$@"
|
2011-08-30 23:09:47 +00:00
|
|
|
eval_gettextln "running \$command"
|
2011-08-05 11:31:30 +00:00
|
|
|
"$@"
|
|
|
|
res=$?
|
|
|
|
|
|
|
|
# Check for really bad run error.
|
2011-08-05 11:31:31 +00:00
|
|
|
if [ $res -lt 0 -o $res -ge 128 ]
|
|
|
|
then
|
2011-08-30 23:09:47 +00:00
|
|
|
eval_gettextln "bisect run failed:
|
|
|
|
exit code \$res from '\$command' is < 0 or >= 128" >&2
|
2011-08-05 11:31:30 +00:00
|
|
|
exit $res
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Find current state depending on run success or failure.
|
|
|
|
# A special exit code of 125 means cannot test.
|
2011-08-05 11:31:31 +00:00
|
|
|
if [ $res -eq 125 ]
|
|
|
|
then
|
2011-08-05 11:31:30 +00:00
|
|
|
state='skip'
|
2011-08-05 11:31:31 +00:00
|
|
|
elif [ $res -gt 0 ]
|
|
|
|
then
|
2015-06-29 15:40:29 +00:00
|
|
|
state="$TERM_BAD"
|
2011-08-05 11:31:30 +00:00
|
|
|
else
|
2015-06-29 15:40:29 +00:00
|
|
|
state="$TERM_GOOD"
|
2011-08-05 11:31:30 +00:00
|
|
|
fi
|
|
|
|
|
2020-10-15 13:38:35 +00:00
|
|
|
git bisect--helper --bisect-state $state >"$GIT_DIR/BISECT_RUN"
|
2011-08-05 11:31:30 +00:00
|
|
|
res=$?
|
|
|
|
|
|
|
|
cat "$GIT_DIR/BISECT_RUN"
|
|
|
|
|
2015-06-29 15:40:29 +00:00
|
|
|
if sane_grep "first $TERM_BAD commit could be any of" "$GIT_DIR/BISECT_RUN" \
|
2014-03-04 00:21:43 +00:00
|
|
|
>/dev/null
|
2011-08-05 11:31:31 +00:00
|
|
|
then
|
2011-08-30 23:09:47 +00:00
|
|
|
gettextln "bisect run cannot continue any more" >&2
|
2011-08-05 11:31:30 +00:00
|
|
|
exit $res
|
|
|
|
fi
|
|
|
|
|
2011-08-05 11:31:31 +00:00
|
|
|
if [ $res -ne 0 ]
|
|
|
|
then
|
2011-08-30 23:09:47 +00:00
|
|
|
eval_gettextln "bisect run failed:
|
2020-10-15 13:38:35 +00:00
|
|
|
'bisect-state \$state' exited with error code \$res" >&2
|
2011-08-05 11:31:30 +00:00
|
|
|
exit $res
|
|
|
|
fi
|
2007-03-23 07:49:59 +00:00
|
|
|
|
2015-06-29 15:40:29 +00:00
|
|
|
if sane_grep "is the first $TERM_BAD commit" "$GIT_DIR/BISECT_RUN" >/dev/null
|
2011-08-05 11:31:31 +00:00
|
|
|
then
|
2011-08-30 23:09:47 +00:00
|
|
|
gettextln "bisect run success"
|
2011-08-05 11:31:30 +00:00
|
|
|
exit 0;
|
|
|
|
fi
|
2007-03-23 07:49:59 +00:00
|
|
|
|
2011-08-05 11:31:30 +00:00
|
|
|
done
|
2007-03-23 07:49:59 +00:00
|
|
|
}
|
|
|
|
|
2015-06-29 15:40:30 +00:00
|
|
|
get_terms () {
|
|
|
|
if test -s "$GIT_DIR/BISECT_TERMS"
|
|
|
|
then
|
|
|
|
{
|
|
|
|
read TERM_BAD
|
|
|
|
read TERM_GOOD
|
|
|
|
} <"$GIT_DIR/BISECT_TERMS"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
[PATCH] Making it easier to find which change introduced a bug
This adds a new "git bisect" command.
- "git bisect start"
start bisection search.
- "git bisect bad <rev>"
mark some version known-bad (if no arguments, then current HEAD)
- "git bisect good <revs>..."
mark some versions known-good (if no arguments, then current HEAD)
- "git bisect reset <branch>"
done with bisection search and go back to your work (if
no arguments, then "master").
The way you use it is:
git bisect start
git bisect bad # Current version is bad
git bisect good v2.6.13-rc2 # v2.6.13-rc2 was the last version
# tested that was good
When you give at least one bad and one good versions, it will
bisect the revision tree and say something like:
Bisecting: 675 revisions left to test after this
and check out the state in the middle. Now, compile that kernel, and boot
it. Now, let's say that this booted kernel works fine, then just do
git bisect good # this one is good
which will now say
Bisecting: 337 revisions left to test after this
and you continue along, compiling that one, testing it, and depending on
whether it is good or bad, you say "git bisect good" or "git bisect bad",
and ask for the next bisection.
Until you have no more left, and you'll have been left with the first bad
kernel rev in "refs/bisect/bad".
Oh, and then after you want to reset to the original head, do a
git bisect reset
to get back to the master branch, instead of being in one of the bisection
branches ("git bisect start" will do that for you too, actually: it will
reset the bisection state, and before it does that it checks that you're
not using some old bisection branch).
Not really any harder than doing series of "quilt push" and "quilt pop",
now is it?
[jc: This patch is a rework based on what Linus posted to the
list. The changes are:
- The original introduced four separate commands, which was
three too many, so I merged them into one with subcommands.
- Since the next thing you would want to do after telling it
"bad" and "good" is always to bisect, this version does it
automatically for you.
- I think the termination condition was wrong. The original
version checked if the set of revisions reachable from next
bisection but not rechable from any of the known good ones
is empty, but if the current bisection was a bad one, this
would not terminate, so I changed it to terminate it when
the set becomes a singleton or empty.
- Removed the use of shell array variable.
]
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-07-30 17:08:20 +00:00
|
|
|
case "$#" in
|
|
|
|
0)
|
2011-08-05 11:31:30 +00:00
|
|
|
usage ;;
|
[PATCH] Making it easier to find which change introduced a bug
This adds a new "git bisect" command.
- "git bisect start"
start bisection search.
- "git bisect bad <rev>"
mark some version known-bad (if no arguments, then current HEAD)
- "git bisect good <revs>..."
mark some versions known-good (if no arguments, then current HEAD)
- "git bisect reset <branch>"
done with bisection search and go back to your work (if
no arguments, then "master").
The way you use it is:
git bisect start
git bisect bad # Current version is bad
git bisect good v2.6.13-rc2 # v2.6.13-rc2 was the last version
# tested that was good
When you give at least one bad and one good versions, it will
bisect the revision tree and say something like:
Bisecting: 675 revisions left to test after this
and check out the state in the middle. Now, compile that kernel, and boot
it. Now, let's say that this booted kernel works fine, then just do
git bisect good # this one is good
which will now say
Bisecting: 337 revisions left to test after this
and you continue along, compiling that one, testing it, and depending on
whether it is good or bad, you say "git bisect good" or "git bisect bad",
and ask for the next bisection.
Until you have no more left, and you'll have been left with the first bad
kernel rev in "refs/bisect/bad".
Oh, and then after you want to reset to the original head, do a
git bisect reset
to get back to the master branch, instead of being in one of the bisection
branches ("git bisect start" will do that for you too, actually: it will
reset the bisection state, and before it does that it checks that you're
not using some old bisection branch).
Not really any harder than doing series of "quilt push" and "quilt pop",
now is it?
[jc: This patch is a rework based on what Linus posted to the
list. The changes are:
- The original introduced four separate commands, which was
three too many, so I merged them into one with subcommands.
- Since the next thing you would want to do after telling it
"bad" and "good" is always to bisect, this version does it
automatically for you.
- I think the termination condition was wrong. The original
version checked if the set of revisions reachable from next
bisection but not rechable from any of the known good ones
is empty, but if the current bisection was a bad one, this
would not terminate, so I changed it to terminate it when
the set becomes a singleton or empty.
- Removed the use of shell array variable.
]
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-07-30 17:08:20 +00:00
|
|
|
*)
|
2011-08-05 11:31:30 +00:00
|
|
|
cmd="$1"
|
2015-06-29 15:40:30 +00:00
|
|
|
get_terms
|
2011-08-05 11:31:30 +00:00
|
|
|
shift
|
|
|
|
case "$cmd" in
|
|
|
|
help)
|
|
|
|
git bisect -h ;;
|
|
|
|
start)
|
2020-10-15 13:38:32 +00:00
|
|
|
git bisect--helper --bisect-start "$@" ;;
|
2015-06-29 15:40:33 +00:00
|
|
|
bad|good|new|old|"$TERM_BAD"|"$TERM_GOOD")
|
2020-10-15 13:38:35 +00:00
|
|
|
git bisect--helper --bisect-state "$cmd" "$@" ;;
|
2011-08-05 11:31:30 +00:00
|
|
|
skip)
|
2021-02-03 21:54:37 +00:00
|
|
|
git bisect--helper --bisect-skip "$@" || exit;;
|
2011-08-05 11:31:30 +00:00
|
|
|
next)
|
|
|
|
# Not sure we want "next" at the UI level anymore.
|
2020-09-24 12:33:40 +00:00
|
|
|
git bisect--helper --bisect-next "$@" || exit ;;
|
2011-08-05 11:31:30 +00:00
|
|
|
visualize|view)
|
|
|
|
bisect_visualize "$@" ;;
|
|
|
|
reset)
|
2019-01-02 15:38:31 +00:00
|
|
|
git bisect--helper --bisect-reset "$@" ;;
|
2011-08-05 11:31:30 +00:00
|
|
|
replay)
|
2021-02-03 21:54:33 +00:00
|
|
|
git bisect--helper --bisect-replay "$@" || exit;;
|
2011-08-05 11:31:30 +00:00
|
|
|
log)
|
2021-02-03 21:54:32 +00:00
|
|
|
git bisect--helper --bisect-log || exit ;;
|
2011-08-05 11:31:30 +00:00
|
|
|
run)
|
|
|
|
bisect_run "$@" ;;
|
2015-06-29 15:40:34 +00:00
|
|
|
terms)
|
2019-01-02 15:38:35 +00:00
|
|
|
git bisect--helper --bisect-terms "$@" || exit;;
|
2011-08-05 11:31:30 +00:00
|
|
|
*)
|
|
|
|
usage ;;
|
|
|
|
esac
|
[PATCH] Making it easier to find which change introduced a bug
This adds a new "git bisect" command.
- "git bisect start"
start bisection search.
- "git bisect bad <rev>"
mark some version known-bad (if no arguments, then current HEAD)
- "git bisect good <revs>..."
mark some versions known-good (if no arguments, then current HEAD)
- "git bisect reset <branch>"
done with bisection search and go back to your work (if
no arguments, then "master").
The way you use it is:
git bisect start
git bisect bad # Current version is bad
git bisect good v2.6.13-rc2 # v2.6.13-rc2 was the last version
# tested that was good
When you give at least one bad and one good versions, it will
bisect the revision tree and say something like:
Bisecting: 675 revisions left to test after this
and check out the state in the middle. Now, compile that kernel, and boot
it. Now, let's say that this booted kernel works fine, then just do
git bisect good # this one is good
which will now say
Bisecting: 337 revisions left to test after this
and you continue along, compiling that one, testing it, and depending on
whether it is good or bad, you say "git bisect good" or "git bisect bad",
and ask for the next bisection.
Until you have no more left, and you'll have been left with the first bad
kernel rev in "refs/bisect/bad".
Oh, and then after you want to reset to the original head, do a
git bisect reset
to get back to the master branch, instead of being in one of the bisection
branches ("git bisect start" will do that for you too, actually: it will
reset the bisection state, and before it does that it checks that you're
not using some old bisection branch).
Not really any harder than doing series of "quilt push" and "quilt pop",
now is it?
[jc: This patch is a rework based on what Linus posted to the
list. The changes are:
- The original introduced four separate commands, which was
three too many, so I merged them into one with subcommands.
- Since the next thing you would want to do after telling it
"bad" and "good" is always to bisect, this version does it
automatically for you.
- I think the termination condition was wrong. The original
version checked if the set of revisions reachable from next
bisection but not rechable from any of the known good ones
is empty, but if the current bisection was a bad one, this
would not terminate, so I changed it to terminate it when
the set becomes a singleton or empty.
- Removed the use of shell array variable.
]
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-07-30 17:08:20 +00:00
|
|
|
esac
|