[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
|
|
|
|
2008-04-11 03:55:21 +00:00
|
|
|
USAGE='[help|start|bad|good|skip|next|reset|visualize|replay|log|run]'
|
|
|
|
LONG_USAGE='git bisect help
|
2011-08-05 11:31:30 +00:00
|
|
|
print this long help message.
|
2011-08-04 12:01:01 +00:00
|
|
|
git bisect start [--no-checkout] [<bad> [<good>...]] [--] [<pathspec>...]
|
2011-08-05 11:31:30 +00:00
|
|
|
reset bisect state and start bisection.
|
2007-04-04 05:12:02 +00:00
|
|
|
git bisect bad [<rev>]
|
2011-08-05 11:31:30 +00:00
|
|
|
mark <rev> a known-bad revision.
|
2007-04-04 05:12:02 +00:00
|
|
|
git bisect good [<rev>...]
|
2011-08-05 11:31:30 +00:00
|
|
|
mark <rev>... known-good revisions.
|
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.
|
2007-04-04 05:12:02 +00:00
|
|
|
git bisect visualize
|
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
|
2011-05-21 18:44:19 +00:00
|
|
|
. git-sh-i18n
|
[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
|
|
|
|
2011-08-04 12:01:01 +00:00
|
|
|
bisect_head()
|
|
|
|
{
|
|
|
|
if test -f "$GIT_DIR/BISECT_HEAD"
|
|
|
|
then
|
|
|
|
echo BISECT_HEAD
|
|
|
|
else
|
|
|
|
echo HEAD
|
|
|
|
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
|
|
|
bisect_autostart() {
|
2008-05-28 16:57:02 +00:00
|
|
|
test -s "$GIT_DIR/BISECT_START" || {
|
2011-08-30 23:09:47 +00:00
|
|
|
gettextln "You need to start by \"git bisect start\"" >&2
|
[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
|
|
|
if test -t 0
|
|
|
|
then
|
2011-05-21 18:44:28 +00:00
|
|
|
# TRANSLATORS: Make sure to include [Y] and [n] in your
|
|
|
|
# translation. The program will only accept English input
|
|
|
|
# at this point.
|
2011-08-05 11:31:30 +00:00
|
|
|
gettext "Do you want me to do it for you [Y/n]? " >&2
|
[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
|
|
|
read yesno
|
|
|
|
case "$yesno" in
|
|
|
|
[Nn]*)
|
|
|
|
exit ;;
|
|
|
|
esac
|
|
|
|
bisect_start
|
|
|
|
else
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bisect_start() {
|
2011-08-04 12:00:57 +00:00
|
|
|
#
|
|
|
|
# Check for one bad and then some good revisions.
|
|
|
|
#
|
|
|
|
has_double_dash=0
|
|
|
|
for arg; do
|
2011-08-05 11:31:30 +00:00
|
|
|
case "$arg" in --) has_double_dash=1; break ;; esac
|
2011-08-04 12:00:57 +00:00
|
|
|
done
|
|
|
|
orig_args=$(git rev-parse --sq-quote "$@")
|
|
|
|
bad_seen=0
|
|
|
|
eval=''
|
2015-06-29 15:40:30 +00:00
|
|
|
must_write_terms=0
|
2015-06-29 15:40:31 +00:00
|
|
|
revs=''
|
2011-08-09 02:11:54 +00:00
|
|
|
if test "z$(git rev-parse --is-bare-repository)" != zfalse
|
|
|
|
then
|
|
|
|
mode=--no-checkout
|
|
|
|
else
|
|
|
|
mode=''
|
|
|
|
fi
|
2011-08-04 12:00:57 +00:00
|
|
|
while [ $# -gt 0 ]; do
|
2011-08-05 11:31:30 +00:00
|
|
|
arg="$1"
|
|
|
|
case "$arg" in
|
|
|
|
--)
|
|
|
|
shift
|
|
|
|
break
|
2011-08-04 12:00:57 +00:00
|
|
|
;;
|
2011-08-05 11:31:30 +00:00
|
|
|
--no-checkout)
|
|
|
|
mode=--no-checkout
|
|
|
|
shift ;;
|
|
|
|
--*)
|
|
|
|
die "$(eval_gettext "unrecognised option: '\$arg'")" ;;
|
|
|
|
*)
|
|
|
|
rev=$(git rev-parse -q --verify "$arg^{commit}") || {
|
2011-08-05 17:09:23 +00:00
|
|
|
test $has_double_dash -eq 1 &&
|
|
|
|
die "$(eval_gettext "'\$arg' does not appear to be a valid revision")"
|
|
|
|
break
|
2011-08-05 11:31:30 +00:00
|
|
|
}
|
2015-06-29 15:40:31 +00:00
|
|
|
revs="$revs $rev"
|
2011-08-05 11:31:30 +00:00
|
|
|
shift
|
|
|
|
;;
|
2011-08-04 12:00:57 +00:00
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2015-06-29 15:40:31 +00:00
|
|
|
for rev in $revs
|
|
|
|
do
|
|
|
|
# The user ran "git bisect start <sha1>
|
|
|
|
# <sha1>", hence did not explicitly specify
|
|
|
|
# the terms, but we are already starting to
|
|
|
|
# set references named with the default terms,
|
|
|
|
# and won't be able to change afterwards.
|
|
|
|
must_write_terms=1
|
|
|
|
|
|
|
|
case $bad_seen in
|
|
|
|
0) state=$TERM_BAD ; bad_seen=1 ;;
|
|
|
|
*) state=$TERM_GOOD ;;
|
|
|
|
esac
|
|
|
|
eval="$eval bisect_write '$state' '$rev' 'nolog' &&"
|
|
|
|
done
|
[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-05-22 23:28:57 +00:00
|
|
|
# Verify HEAD.
|
[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-04-16 02:09:49 +00:00
|
|
|
head=$(GIT_DIR="$GIT_DIR" git symbolic-ref -q HEAD) ||
|
2008-02-10 13:59:50 +00:00
|
|
|
head=$(GIT_DIR="$GIT_DIR" git rev-parse --verify HEAD) ||
|
2011-05-21 18:44:23 +00:00
|
|
|
die "$(gettext "Bad HEAD - I need a HEAD")"
|
2008-05-22 23:28:57 +00:00
|
|
|
|
2008-05-05 07:43:00 +00:00
|
|
|
#
|
2008-05-22 23:28:57 +00:00
|
|
|
# Check if we are bisecting.
|
2008-05-05 07:43:00 +00:00
|
|
|
#
|
git-bisect: make "start", "good" and "skip" succeed or fail atomically
Before this patch, when "git bisect start", "git bisect good" or
"git bisect skip" were called with many revisions, they could fail
after having already marked some revisions as "good", "bad" or
"skip".
This could be especilally bad for "git bisect start" because as
the file ".git/BISECT_NAMES" would not have been written, there
would have been no attempt to clear the marked revisions on a
"git bisect reset". That's because if there is no
".git/BISECT_NAMES" file, nothing is done to clean things up, as
the bisect session is not supposed to have started.
While at it, let's also create the ".git/BISECT_START" file, only
after ".git/BISECT_NAMES" as been created.
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-04-14 03:41:45 +00:00
|
|
|
start_head=''
|
2008-05-22 23:28:57 +00:00
|
|
|
if test -s "$GIT_DIR/BISECT_START"
|
|
|
|
then
|
|
|
|
# Reset to the rev from where we started.
|
2008-05-22 22:38:59 +00:00
|
|
|
start_head=$(cat "$GIT_DIR/BISECT_START")
|
2011-08-04 12:01:01 +00:00
|
|
|
if test "z$mode" != "z--no-checkout"
|
|
|
|
then
|
2011-09-21 05:17:24 +00:00
|
|
|
git checkout "$start_head" -- ||
|
2015-01-13 07:44:47 +00:00
|
|
|
die "$(eval_gettext "Checking out '\$start_head' failed. Try 'git bisect reset <valid-branch>'.")"
|
2011-08-04 12:01:01 +00:00
|
|
|
fi
|
2008-05-22 23:28:57 +00:00
|
|
|
else
|
|
|
|
# Get rev from where we start.
|
|
|
|
case "$head" in
|
|
|
|
refs/heads/*|$_x40)
|
|
|
|
# This error message should only be triggered by
|
|
|
|
# cogito usage, and cogito users should understand
|
|
|
|
# it relates to cg-seek.
|
|
|
|
[ -s "$GIT_DIR/head-name" ] &&
|
2013-11-12 15:17:42 +00:00
|
|
|
die "$(gettext "won't bisect on cg-seek'ed tree")"
|
2008-05-22 23:28:57 +00:00
|
|
|
start_head="${head#refs/heads/}"
|
|
|
|
;;
|
|
|
|
*)
|
2011-05-21 18:44:23 +00:00
|
|
|
die "$(gettext "Bad HEAD - strange symbolic ref")"
|
2008-05-22 23:28:57 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
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
|
|
|
|
|
|
|
#
|
2008-05-22 23:28:57 +00:00
|
|
|
# Get rid of any old bisect state.
|
[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-05-28 16:57:02 +00:00
|
|
|
bisect_clean_state || exit
|
2007-04-04 05:12:02 +00:00
|
|
|
|
2008-05-22 22:39:22 +00:00
|
|
|
#
|
|
|
|
# Change state.
|
|
|
|
# In case of mistaken revs or checkout error, or signals received,
|
|
|
|
# "bisect_auto_next" below may exit or misbehave.
|
|
|
|
# We have to trap this to be able to clean up using
|
|
|
|
# "bisect_clean_state".
|
|
|
|
#
|
|
|
|
trap 'bisect_clean_state' 0
|
|
|
|
trap 'exit 255' 1 2 3 15
|
|
|
|
|
|
|
|
#
|
|
|
|
# Write new start state.
|
|
|
|
#
|
2011-08-04 12:01:01 +00:00
|
|
|
echo "$start_head" >"$GIT_DIR/BISECT_START" && {
|
|
|
|
test "z$mode" != "z--no-checkout" ||
|
|
|
|
git update-ref --no-deref BISECT_HEAD "$start_head"
|
|
|
|
} &&
|
2009-04-24 06:29:00 +00:00
|
|
|
git rev-parse --sq-quote "$@" >"$GIT_DIR/BISECT_NAMES" &&
|
2011-08-04 12:00:58 +00:00
|
|
|
eval "$eval true" &&
|
2015-06-29 15:40:30 +00:00
|
|
|
if test $must_write_terms -eq 1
|
|
|
|
then
|
|
|
|
write_terms "$TERM_BAD" "$TERM_GOOD"
|
|
|
|
fi &&
|
2008-07-11 16:01:29 +00:00
|
|
|
echo "git bisect start$orig_args" >>"$GIT_DIR/BISECT_LOG" || exit
|
2008-05-22 22:39:22 +00:00
|
|
|
#
|
|
|
|
# Check if we can proceed to the next bisect state.
|
|
|
|
#
|
2007-04-04 05:12:02 +00:00
|
|
|
bisect_auto_next
|
2008-05-22 22:39:22 +00:00
|
|
|
|
|
|
|
trap '-' 0
|
[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
|
|
|
}
|
|
|
|
|
2007-10-24 05:01:05 +00:00
|
|
|
bisect_write() {
|
|
|
|
state="$1"
|
|
|
|
rev="$2"
|
2007-10-24 05:01:13 +00:00
|
|
|
nolog="$3"
|
2007-10-24 05:01:05 +00:00
|
|
|
case "$state" in
|
2015-06-29 15:40:29 +00:00
|
|
|
"$TERM_BAD")
|
|
|
|
tag="$state" ;;
|
|
|
|
"$TERM_GOOD"|skip)
|
|
|
|
tag="$state"-"$rev" ;;
|
|
|
|
*)
|
|
|
|
die "$(eval_gettext "Bad bisect_write argument: \$state")" ;;
|
2007-10-24 05:01:05 +00:00
|
|
|
esac
|
2008-05-22 22:39:22 +00:00
|
|
|
git update-ref "refs/bisect/$tag" "$rev" || exit
|
2008-02-12 19:50:57 +00:00
|
|
|
echo "# $state: $(git show-branch $rev)" >>"$GIT_DIR/BISECT_LOG"
|
2008-07-11 16:01:29 +00:00
|
|
|
test -n "$nolog" || echo "git bisect $state $rev" >>"$GIT_DIR/BISECT_LOG"
|
2007-10-24 05:01:05 +00:00
|
|
|
}
|
|
|
|
|
2008-08-22 03:52:29 +00:00
|
|
|
is_expected_rev() {
|
|
|
|
test -f "$GIT_DIR/BISECT_EXPECTED_REV" &&
|
|
|
|
test "$1" = $(cat "$GIT_DIR/BISECT_EXPECTED_REV")
|
|
|
|
}
|
|
|
|
|
|
|
|
check_expected_revs() {
|
|
|
|
for _rev in "$@"; do
|
2011-08-05 11:31:31 +00:00
|
|
|
if ! is_expected_rev "$_rev"
|
|
|
|
then
|
2008-08-22 03:52:29 +00:00
|
|
|
rm -f "$GIT_DIR/BISECT_ANCESTORS_OK"
|
|
|
|
rm -f "$GIT_DIR/BISECT_EXPECTED_REV"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2008-11-23 21:02:49 +00:00
|
|
|
bisect_skip() {
|
2011-08-05 11:31:30 +00:00
|
|
|
all=''
|
2008-11-23 21:02:49 +00:00
|
|
|
for arg in "$@"
|
|
|
|
do
|
2011-08-05 11:31:30 +00:00
|
|
|
case "$arg" in
|
|
|
|
*..*)
|
|
|
|
revs=$(git rev-list "$arg") || die "$(eval_gettext "Bad rev input: \$arg")" ;;
|
|
|
|
*)
|
|
|
|
revs=$(git rev-parse --sq-quote "$arg") ;;
|
|
|
|
esac
|
|
|
|
all="$all $revs"
|
|
|
|
done
|
|
|
|
eval bisect_state 'skip' $all
|
2008-11-23 21:02:49 +00:00
|
|
|
}
|
|
|
|
|
2007-10-24 05:01:21 +00:00
|
|
|
bisect_state() {
|
[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
|
|
|
bisect_autostart
|
2007-10-24 05:01:21 +00:00
|
|
|
state=$1
|
2015-06-29 15:40:30 +00:00
|
|
|
check_and_set_terms $state
|
2007-10-24 05:01:21 +00:00
|
|
|
case "$#,$state" in
|
|
|
|
0,*)
|
2011-05-21 18:44:23 +00:00
|
|
|
die "$(gettext "Please call 'bisect_state' with at least one argument.")" ;;
|
2015-06-29 15:40:29 +00:00
|
|
|
1,"$TERM_BAD"|1,"$TERM_GOOD"|1,skip)
|
2011-08-04 12:01:01 +00:00
|
|
|
rev=$(git rev-parse --verify $(bisect_head)) ||
|
|
|
|
die "$(gettext "Bad rev input: $(bisect_head)")"
|
2008-08-22 03:52:29 +00:00
|
|
|
bisect_write "$state" "$rev"
|
|
|
|
check_expected_revs "$rev" ;;
|
2015-06-29 15:40:29 +00:00
|
|
|
2,"$TERM_BAD"|*,"$TERM_GOOD"|*,skip)
|
2007-10-24 05:01:21 +00:00
|
|
|
shift
|
2014-12-25 18:25:32 +00:00
|
|
|
hash_list=''
|
2008-04-12 05:53:59 +00:00
|
|
|
for rev in "$@"
|
2007-10-24 05:01:21 +00:00
|
|
|
do
|
2008-04-12 09:17:36 +00:00
|
|
|
sha=$(git rev-parse --verify "$rev^{commit}") ||
|
2011-05-21 18:44:24 +00:00
|
|
|
die "$(eval_gettext "Bad rev input: \$rev")"
|
2014-12-25 18:25:32 +00:00
|
|
|
hash_list="$hash_list $sha"
|
git-bisect: make "start", "good" and "skip" succeed or fail atomically
Before this patch, when "git bisect start", "git bisect good" or
"git bisect skip" were called with many revisions, they could fail
after having already marked some revisions as "good", "bad" or
"skip".
This could be especilally bad for "git bisect start" because as
the file ".git/BISECT_NAMES" would not have been written, there
would have been no attempt to clear the marked revisions on a
"git bisect reset". That's because if there is no
".git/BISECT_NAMES" file, nothing is done to clean things up, as
the bisect session is not supposed to have started.
While at it, let's also create the ".git/BISECT_START" file, only
after ".git/BISECT_NAMES" as been created.
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-04-14 03:41:45 +00:00
|
|
|
done
|
2014-12-25 18:25:32 +00:00
|
|
|
for rev in $hash_list
|
|
|
|
do
|
|
|
|
bisect_write "$state" "$rev"
|
|
|
|
done
|
|
|
|
check_expected_revs $hash_list ;;
|
2015-06-29 15:40:29 +00:00
|
|
|
*,"$TERM_BAD")
|
|
|
|
die "$(eval_gettext "'git bisect \$TERM_BAD' can take only one argument.")" ;;
|
2005-08-30 19:45:41 +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
|
|
|
esac
|
2007-10-22 05:48:36 +00:00
|
|
|
bisect_auto_next
|
|
|
|
}
|
|
|
|
|
[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
|
|
|
bisect_next_check() {
|
2007-04-06 06:27:44 +00:00
|
|
|
missing_good= missing_bad=
|
2015-06-29 15:40:29 +00:00
|
|
|
git show-ref -q --verify refs/bisect/$TERM_BAD || missing_bad=t
|
|
|
|
test -n "$(git for-each-ref "refs/bisect/$TERM_GOOD-*")" || missing_good=t
|
2007-04-06 05:51:14 +00:00
|
|
|
|
2007-04-06 06:27:44 +00:00
|
|
|
case "$missing_good,$missing_bad,$1" in
|
|
|
|
,,*)
|
2015-06-29 15:40:29 +00:00
|
|
|
: have both $TERM_GOOD and $TERM_BAD - ok
|
2007-04-06 06:27:44 +00:00
|
|
|
;;
|
|
|
|
*,)
|
|
|
|
# do not have both but not asked to fail - just report.
|
|
|
|
false
|
|
|
|
;;
|
2015-06-29 15:40:29 +00:00
|
|
|
t,,"$TERM_GOOD")
|
2007-04-06 06:27:44 +00:00
|
|
|
# have bad but not good. we could bisect although
|
|
|
|
# this is less optimum.
|
2015-06-29 15:40:29 +00:00
|
|
|
eval_gettextln "Warning: bisecting only with a \$TERM_BAD commit." >&2
|
2007-04-06 06:27:44 +00:00
|
|
|
if test -t 0
|
|
|
|
then
|
2011-05-21 18:44:28 +00:00
|
|
|
# TRANSLATORS: Make sure to include [Y] and [n] in your
|
|
|
|
# translation. The program will only accept English input
|
|
|
|
# at this point.
|
|
|
|
gettext "Are you sure [Y/n]? " >&2
|
2008-08-11 17:37:46 +00:00
|
|
|
read yesno
|
|
|
|
case "$yesno" in [Nn]*) exit 1 ;; esac
|
2007-04-06 06:27:44 +00:00
|
|
|
fi
|
2015-06-29 15:40:29 +00:00
|
|
|
: bisect without $TERM_GOOD...
|
2007-04-06 06:27:44 +00:00
|
|
|
;;
|
[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
|
|
|
*)
|
2015-06-29 15:40:30 +00:00
|
|
|
bad_syn=$(bisect_voc bad)
|
|
|
|
good_syn=$(bisect_voc good)
|
2011-05-21 18:44:29 +00:00
|
|
|
if test -s "$GIT_DIR/BISECT_START"
|
|
|
|
then
|
2015-06-29 15:40:30 +00:00
|
|
|
|
|
|
|
eval_gettextln "You need to give me at least one \$bad_syn and one \$good_syn revision.
|
|
|
|
(You can use \"git bisect \$bad_syn\" and \"git bisect \$good_syn\" for that.)" >&2
|
2011-05-21 18:44:29 +00:00
|
|
|
else
|
2015-06-29 15:40:30 +00:00
|
|
|
eval_gettextln "You need to start by \"git bisect start\".
|
|
|
|
You then need to give me at least one \$good_syn and one \$bad_syn revision.
|
|
|
|
(You can use \"git bisect \$bad_syn\" and \"git bisect \$good_syn\" for that.)" >&2
|
2011-05-21 18:44:29 +00:00
|
|
|
fi
|
2007-04-06 06:27:44 +00:00
|
|
|
exit 1 ;;
|
[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
|
|
|
|
}
|
|
|
|
|
|
|
|
bisect_auto_next() {
|
2005-09-17 20:51:03 +00:00
|
|
|
bisect_next_check && bisect_next || :
|
[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
|
|
|
}
|
|
|
|
|
|
|
|
bisect_next() {
|
2007-10-22 05:48:23 +00:00
|
|
|
case "$#" in 0) ;; *) 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
|
|
|
bisect_autostart
|
2015-06-29 15:40:29 +00:00
|
|
|
bisect_next_check $TERM_GOOD
|
2007-04-06 06:27:44 +00:00
|
|
|
|
2009-05-09 15:55:47 +00:00
|
|
|
# Perform all bisection computation, display and checkout
|
2011-08-04 12:01:01 +00:00
|
|
|
git bisect--helper --next-all $(test -f "$GIT_DIR/BISECT_HEAD" && echo --no-checkout)
|
2009-04-19 09:56:16 +00:00
|
|
|
res=$?
|
2007-04-06 06:27:44 +00:00
|
|
|
|
2011-08-05 11:31:30 +00:00
|
|
|
# Check if we should exit because bisection is finished
|
2013-04-13 15:22:57 +00:00
|
|
|
if test $res -eq 10
|
|
|
|
then
|
2015-06-29 15:40:29 +00:00
|
|
|
bad_rev=$(git show-ref --hash --verify refs/bisect/$TERM_BAD)
|
2013-04-13 15:22:57 +00:00
|
|
|
bad_commit=$(git show-branch $bad_rev)
|
2015-06-29 15:40:29 +00:00
|
|
|
echo "# first $TERM_BAD commit: $bad_commit" >>"$GIT_DIR/BISECT_LOG"
|
2013-04-13 15:22:57 +00:00
|
|
|
exit 0
|
2013-04-22 21:02:29 +00:00
|
|
|
elif test $res -eq 2
|
|
|
|
then
|
|
|
|
echo "# only skipped commits left to test" >>"$GIT_DIR/BISECT_LOG"
|
2015-06-29 15:40:29 +00:00
|
|
|
good_revs=$(git for-each-ref --format="%(objectname)" "refs/bisect/$TERM_GOOD-*")
|
|
|
|
for skipped in $(git rev-list refs/bisect/$TERM_BAD --not $good_revs)
|
2013-04-22 21:02:29 +00:00
|
|
|
do
|
|
|
|
skipped_commit=$(git show-branch $skipped)
|
2015-06-29 15:40:29 +00:00
|
|
|
echo "# possible first $TERM_BAD commit: $skipped_commit" >>"$GIT_DIR/BISECT_LOG"
|
2013-04-22 21:02:29 +00:00
|
|
|
done
|
|
|
|
exit $res
|
2013-04-13 15:22:57 +00:00
|
|
|
fi
|
2007-04-06 06:27:44 +00:00
|
|
|
|
2009-04-19 09:56:16 +00:00
|
|
|
# Check for an error in the bisection process
|
|
|
|
test $res -ne 0 && exit $res
|
|
|
|
|
|
|
|
return 0
|
[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
|
|
|
}
|
|
|
|
|
2005-08-30 19:45:41 +00:00
|
|
|
bisect_visualize() {
|
|
|
|
bisect_next_check fail
|
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
|
|
|
}
|
|
|
|
|
[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
|
|
|
bisect_reset() {
|
2008-05-28 16:57:02 +00:00
|
|
|
test -s "$GIT_DIR/BISECT_START" || {
|
2011-08-30 23:09:47 +00:00
|
|
|
gettextln "We are not bisecting."
|
2007-11-20 05:39:53 +00:00
|
|
|
return
|
|
|
|
}
|
[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
|
2008-05-28 16:57:02 +00:00
|
|
|
0) branch=$(cat "$GIT_DIR/BISECT_START") ;;
|
2014-03-04 00:21:43 +00:00
|
|
|
1) git rev-parse --quiet --verify "$1^{commit}" >/dev/null || {
|
2011-08-05 11:31:30 +00:00
|
|
|
invalid="$1"
|
|
|
|
die "$(eval_gettext "'\$invalid' is not a valid commit")"
|
|
|
|
}
|
|
|
|
branch="$1" ;;
|
2007-10-22 05:48:23 +00:00
|
|
|
*)
|
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
|
|
|
esac
|
2011-08-05 17:09:23 +00:00
|
|
|
|
|
|
|
if ! test -f "$GIT_DIR/BISECT_HEAD" && ! git checkout "$branch" --
|
2011-08-04 12:01:01 +00:00
|
|
|
then
|
2011-08-05 17:09:23 +00:00
|
|
|
die "$(eval_gettext "Could not check out original HEAD '\$branch'.
|
2011-05-21 18:44:24 +00:00
|
|
|
Try 'git bisect reset <commit>'.")"
|
2010-10-10 21:48:57 +00:00
|
|
|
fi
|
2011-08-04 12:01:01 +00:00
|
|
|
bisect_clean_state
|
2005-09-10 22:18:31 +00:00
|
|
|
}
|
|
|
|
|
2007-04-04 05:12:02 +00:00
|
|
|
bisect_clean_state() {
|
2007-11-15 07:18:07 +00:00
|
|
|
# There may be some refs packed during bisection.
|
2008-05-22 23:28:57 +00:00
|
|
|
git for-each-ref --format='%(refname) %(objectname)' refs/bisect/\* |
|
2007-11-15 07:18:07 +00:00
|
|
|
while read ref hash
|
|
|
|
do
|
2008-05-28 16:57:02 +00:00
|
|
|
git update-ref -d $ref $hash || exit
|
2007-11-15 07:18:07 +00:00
|
|
|
done
|
2008-08-22 03:52:29 +00:00
|
|
|
rm -f "$GIT_DIR/BISECT_EXPECTED_REV" &&
|
|
|
|
rm -f "$GIT_DIR/BISECT_ANCESTORS_OK" &&
|
2008-05-28 16:57:02 +00:00
|
|
|
rm -f "$GIT_DIR/BISECT_LOG" &&
|
|
|
|
rm -f "$GIT_DIR/BISECT_NAMES" &&
|
|
|
|
rm -f "$GIT_DIR/BISECT_RUN" &&
|
2015-06-29 15:40:30 +00:00
|
|
|
rm -f "$GIT_DIR/BISECT_TERMS" &&
|
2008-05-22 22:38:59 +00:00
|
|
|
# Cleanup head-name if it got left by an old version of git-bisect
|
2008-05-28 16:57:02 +00:00
|
|
|
rm -f "$GIT_DIR/head-name" &&
|
2011-08-04 12:01:01 +00:00
|
|
|
git update-ref -d --no-deref BISECT_HEAD &&
|
|
|
|
# clean up BISECT_START last
|
2008-05-28 16:57:02 +00:00
|
|
|
rm -f "$GIT_DIR/BISECT_START"
|
2007-04-04 05:12:02 +00:00
|
|
|
}
|
|
|
|
|
2005-09-10 22:18:31 +00:00
|
|
|
bisect_replay () {
|
2011-05-21 18:44:27 +00:00
|
|
|
file="$1"
|
|
|
|
test "$#" -eq 1 || die "$(gettext "No logfile given")"
|
|
|
|
test -r "$file" || die "$(eval_gettext "cannot read \$file for replaying")"
|
2005-09-10 22:18:31 +00:00
|
|
|
bisect_reset
|
2008-07-11 16:01:29 +00:00
|
|
|
while read git bisect command rev
|
2005-09-10 22:18:31 +00:00
|
|
|
do
|
2014-06-06 14:55:50 +00:00
|
|
|
test "$git $bisect" = "git bisect" || test "$git" = "git-bisect" || continue
|
2011-08-05 11:31:31 +00:00
|
|
|
if test "$git" = "git-bisect"
|
|
|
|
then
|
2008-07-11 16:01:29 +00:00
|
|
|
rev="$command"
|
|
|
|
command="$bisect"
|
|
|
|
fi
|
2015-06-29 15:40:30 +00:00
|
|
|
get_terms
|
|
|
|
check_and_set_terms "$command"
|
2005-09-10 22:18:31 +00:00
|
|
|
case "$command" in
|
|
|
|
start)
|
2005-11-28 01:42:05 +00:00
|
|
|
cmd="bisect_start $rev"
|
2007-10-24 05:01:13 +00:00
|
|
|
eval "$cmd" ;;
|
2015-06-29 15:40:30 +00:00
|
|
|
"$TERM_GOOD"|"$TERM_BAD"|skip)
|
2007-10-24 05:01:13 +00:00
|
|
|
bisect_write "$command" "$rev" ;;
|
2005-09-10 22:18:31 +00:00
|
|
|
*)
|
2011-05-21 18:44:23 +00:00
|
|
|
die "$(gettext "?? what are you talking about?")" ;;
|
2005-09-10 22:18:31 +00:00
|
|
|
esac
|
2011-05-21 18:44:27 +00:00
|
|
|
done <"$file"
|
2005-09-10 22:18:31 +00:00
|
|
|
bisect_auto_next
|
[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
|
|
|
}
|
|
|
|
|
2007-03-23 07:49:59 +00:00
|
|
|
bisect_run () {
|
2011-08-05 11:31:30 +00:00
|
|
|
bisect_next_check fail
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
# We have to use a subshell because "bisect_state" can exit.
|
2014-03-04 00:21:43 +00:00
|
|
|
( 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:
|
|
|
|
'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
|
|
|
}
|
|
|
|
|
2010-10-10 21:48:56 +00:00
|
|
|
bisect_log () {
|
2011-05-21 18:44:23 +00:00
|
|
|
test -s "$GIT_DIR/BISECT_LOG" || die "$(gettext "We are not bisecting.")"
|
2010-10-10 21:48:56 +00:00
|
|
|
cat "$GIT_DIR/BISECT_LOG"
|
|
|
|
}
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
write_terms () {
|
|
|
|
TERM_BAD=$1
|
|
|
|
TERM_GOOD=$2
|
2015-06-29 15:40:32 +00:00
|
|
|
if test "$TERM_BAD" = "$TERM_GOOD"
|
|
|
|
then
|
|
|
|
die "$(gettext "please use two different terms")"
|
|
|
|
fi
|
|
|
|
check_term_format "$TERM_BAD" bad
|
|
|
|
check_term_format "$TERM_GOOD" good
|
2015-06-29 15:40:30 +00:00
|
|
|
printf '%s\n%s\n' "$TERM_BAD" "$TERM_GOOD" >"$GIT_DIR/BISECT_TERMS"
|
|
|
|
}
|
|
|
|
|
2015-06-29 15:40:32 +00:00
|
|
|
check_term_format () {
|
|
|
|
term=$1
|
|
|
|
git check-ref-format refs/bisect/"$term" ||
|
|
|
|
die "$(eval_gettext "'\$term' is not a valid term")"
|
|
|
|
case "$term" in
|
|
|
|
help|start|terms|skip|next|reset|visualize|replay|log|run)
|
|
|
|
die "$(eval_gettext "can't use the builtin command '\$term' as a term")"
|
|
|
|
;;
|
|
|
|
bad|new)
|
|
|
|
if test "$2" != bad
|
|
|
|
then
|
|
|
|
# In theory, nothing prevents swapping
|
|
|
|
# completely good and bad, but this situation
|
|
|
|
# could be confusing and hasn't been tested
|
|
|
|
# enough. Forbid it for now.
|
|
|
|
die "$(eval_gettext "can't change the meaning of term '\$term'")"
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
good|old)
|
|
|
|
if test "$2" != good
|
|
|
|
then
|
|
|
|
die "$(eval_gettext "can't change the meaning of term '\$term'")"
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2015-06-29 15:40:30 +00:00
|
|
|
check_and_set_terms () {
|
|
|
|
cmd="$1"
|
|
|
|
case "$cmd" in
|
|
|
|
skip|start|terms) ;;
|
|
|
|
*)
|
|
|
|
if test -s "$GIT_DIR/BISECT_TERMS" && test "$cmd" != "$TERM_BAD" && test "$cmd" != "$TERM_GOOD"
|
|
|
|
then
|
|
|
|
die "$(eval_gettext "Invalid command: you're currently in a \$TERM_BAD/\$TERM_GOOD bisect.")"
|
|
|
|
fi
|
|
|
|
case "$cmd" in
|
|
|
|
bad|good)
|
|
|
|
if ! test -s "$GIT_DIR/BISECT_TERMS"
|
|
|
|
then
|
|
|
|
write_terms bad good
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac ;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
bisect_voc () {
|
|
|
|
case "$1" in
|
|
|
|
bad) echo "bad" ;;
|
|
|
|
good) echo "good" ;;
|
|
|
|
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
|
|
|
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)
|
|
|
|
bisect_start "$@" ;;
|
2015-06-29 15:40:30 +00:00
|
|
|
bad|good|"$TERM_BAD"|"$TERM_GOOD")
|
2011-08-05 11:31:30 +00:00
|
|
|
bisect_state "$cmd" "$@" ;;
|
|
|
|
skip)
|
|
|
|
bisect_skip "$@" ;;
|
|
|
|
next)
|
|
|
|
# Not sure we want "next" at the UI level anymore.
|
|
|
|
bisect_next "$@" ;;
|
|
|
|
visualize|view)
|
|
|
|
bisect_visualize "$@" ;;
|
|
|
|
reset)
|
|
|
|
bisect_reset "$@" ;;
|
|
|
|
replay)
|
|
|
|
bisect_replay "$@" ;;
|
|
|
|
log)
|
|
|
|
bisect_log ;;
|
|
|
|
run)
|
|
|
|
bisect_run "$@" ;;
|
|
|
|
*)
|
|
|
|
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
|