[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 19:08:20 +02:00
|
|
|
#!/bin/sh
|
2005-12-11 10:55:49 +01:00
|
|
|
|
2008-04-11 05:55:21 +02:00
|
|
|
USAGE='[help|start|bad|good|skip|next|reset|visualize|replay|log|run]'
|
|
|
|
LONG_USAGE='git bisect help
|
|
|
|
print this long help message.
|
|
|
|
git bisect start [<bad> [<good>...]] [--] [<pathspec>...]
|
2007-04-04 07:12:02 +02:00
|
|
|
reset bisect state and start bisection.
|
|
|
|
git bisect bad [<rev>]
|
|
|
|
mark <rev> a known-bad revision.
|
|
|
|
git bisect good [<rev>...]
|
|
|
|
mark <rev>... known-good revisions.
|
2007-10-29 05:31:52 +01:00
|
|
|
git bisect skip [<rev>...]
|
|
|
|
mark <rev>... untestable revisions.
|
2007-04-04 07:12:02 +02:00
|
|
|
git bisect next
|
|
|
|
find next bisection to test and check it out.
|
|
|
|
git bisect reset [<branch>]
|
|
|
|
finish bisection search and go back to branch.
|
|
|
|
git bisect visualize
|
|
|
|
show bisect status in gitk.
|
|
|
|
git bisect replay <logfile>
|
|
|
|
replay bisection log.
|
|
|
|
git bisect log
|
|
|
|
show bisect log.
|
|
|
|
git bisect run <cmd>...
|
2008-04-11 05:55:21 +02:00
|
|
|
use <cmd>... to automatically bisect.
|
|
|
|
|
|
|
|
Please use "git help bisect" to get the full man page.'
|
2005-12-11 10:55:49 +01:00
|
|
|
|
2007-11-06 10:50:02 +01:00
|
|
|
OPTIONS_SPEC=
|
2005-11-24 09:12:11 +01:00
|
|
|
. git-sh-setup
|
2007-02-05 23:03:27 +01:00
|
|
|
require_work_tree
|
[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 19:08:20 +02:00
|
|
|
|
2008-02-10 14:59:50 +01: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"
|
|
|
|
|
2005-11-28 02:42:05 +01:00
|
|
|
sq() {
|
2006-07-08 17:32:04 +02:00
|
|
|
@@PERL@@ -e '
|
2005-11-28 02:42:05 +01:00
|
|
|
for (@ARGV) {
|
|
|
|
s/'\''/'\'\\\\\'\''/g;
|
|
|
|
print " '\''$_'\''";
|
|
|
|
}
|
|
|
|
print "\n";
|
|
|
|
' "$@"
|
|
|
|
}
|
|
|
|
|
[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 19:08:20 +02:00
|
|
|
bisect_autostart() {
|
2008-05-28 18:57:02 +02:00
|
|
|
test -s "$GIT_DIR/BISECT_START" || {
|
[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 19:08:20 +02:00
|
|
|
echo >&2 'You need to start by "git bisect start"'
|
|
|
|
if test -t 0
|
|
|
|
then
|
|
|
|
echo >&2 -n 'Do you want me to do it for you [Y/n]? '
|
|
|
|
read yesno
|
|
|
|
case "$yesno" in
|
|
|
|
[Nn]*)
|
|
|
|
exit ;;
|
|
|
|
esac
|
|
|
|
bisect_start
|
|
|
|
else
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bisect_start() {
|
|
|
|
#
|
2008-05-23 01:28:57 +02: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 19:08:20 +02:00
|
|
|
#
|
2008-04-16 04:09:49 +02:00
|
|
|
head=$(GIT_DIR="$GIT_DIR" git symbolic-ref -q HEAD) ||
|
2008-02-10 14:59:50 +01:00
|
|
|
head=$(GIT_DIR="$GIT_DIR" git rev-parse --verify HEAD) ||
|
|
|
|
die "Bad HEAD - I need a HEAD"
|
2008-05-23 01:28:57 +02:00
|
|
|
|
2008-05-05 09:43:00 +02:00
|
|
|
#
|
2008-05-23 01:28:57 +02:00
|
|
|
# Check if we are bisecting.
|
2008-05-05 09:43:00 +02: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 05:41:45 +02:00
|
|
|
start_head=''
|
2008-05-23 01:28:57 +02:00
|
|
|
if test -s "$GIT_DIR/BISECT_START"
|
|
|
|
then
|
|
|
|
# Reset to the rev from where we started.
|
2008-05-23 00:38:59 +02:00
|
|
|
start_head=$(cat "$GIT_DIR/BISECT_START")
|
|
|
|
git checkout "$start_head" || exit
|
2008-05-23 01:28:57 +02: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" ] &&
|
|
|
|
die "won't bisect on seeked tree"
|
|
|
|
start_head="${head#refs/heads/}"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
die "Bad HEAD - strange symbolic ref"
|
|
|
|
;;
|
|
|
|
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 19:08:20 +02:00
|
|
|
|
|
|
|
#
|
2008-05-23 01:28:57 +02: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 19:08:20 +02:00
|
|
|
#
|
2008-05-28 18:57:02 +02:00
|
|
|
bisect_clean_state || exit
|
2007-04-04 07:12:02 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# Check for one bad and then some good revisions.
|
|
|
|
#
|
|
|
|
has_double_dash=0
|
|
|
|
for arg; do
|
|
|
|
case "$arg" in --) has_double_dash=1; break ;; esac
|
|
|
|
done
|
|
|
|
orig_args=$(sq "$@")
|
|
|
|
bad_seen=0
|
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 05:41:45 +02:00
|
|
|
eval=''
|
2007-04-04 07:12:02 +02:00
|
|
|
while [ $# -gt 0 ]; do
|
|
|
|
arg="$1"
|
|
|
|
case "$arg" in
|
|
|
|
--)
|
2007-10-22 07:48:23 +02:00
|
|
|
shift
|
2007-04-04 07:12:02 +02:00
|
|
|
break
|
|
|
|
;;
|
|
|
|
*)
|
2008-05-23 01:28:57 +02:00
|
|
|
rev=$(git rev-parse -q --verify "$arg^{commit}") || {
|
2007-04-04 07:12:02 +02:00
|
|
|
test $has_double_dash -eq 1 &&
|
|
|
|
die "'$arg' does not appear to be a valid revision"
|
|
|
|
break
|
|
|
|
}
|
2007-10-24 07:01:13 +02:00
|
|
|
case $bad_seen in
|
|
|
|
0) state='bad' ; bad_seen=1 ;;
|
|
|
|
*) state='good' ;;
|
|
|
|
esac
|
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 05:41:45 +02:00
|
|
|
eval="$eval bisect_write '$state' '$rev' 'nolog'; "
|
2007-10-22 07:48:23 +02:00
|
|
|
shift
|
2007-04-04 07:12:02 +02:00
|
|
|
;;
|
|
|
|
esac
|
2007-10-22 07:48:23 +02:00
|
|
|
done
|
2007-04-04 07:12:02 +02:00
|
|
|
|
2008-05-23 00:39:22 +02: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.
|
|
|
|
#
|
|
|
|
echo "$start_head" >"$GIT_DIR/BISECT_START" &&
|
2008-05-28 18:57:02 +02:00
|
|
|
sq "$@" >"$GIT_DIR/BISECT_NAMES" &&
|
2008-05-23 00:39:22 +02:00
|
|
|
eval "$eval" &&
|
2008-07-11 18:01:29 +02:00
|
|
|
echo "git bisect start$orig_args" >>"$GIT_DIR/BISECT_LOG" || exit
|
2008-05-23 00:39:22 +02:00
|
|
|
#
|
|
|
|
# Check if we can proceed to the next bisect state.
|
|
|
|
#
|
2007-04-04 07:12:02 +02:00
|
|
|
bisect_auto_next
|
2008-05-23 00:39:22 +02: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 19:08:20 +02:00
|
|
|
}
|
|
|
|
|
2007-10-24 07:01:05 +02:00
|
|
|
bisect_write() {
|
|
|
|
state="$1"
|
|
|
|
rev="$2"
|
2007-10-24 07:01:13 +02:00
|
|
|
nolog="$3"
|
2007-10-24 07:01:05 +02:00
|
|
|
case "$state" in
|
|
|
|
bad) tag="$state" ;;
|
|
|
|
good|skip) tag="$state"-"$rev" ;;
|
|
|
|
*) die "Bad bisect_write argument: $state" ;;
|
|
|
|
esac
|
2008-05-23 00:39:22 +02:00
|
|
|
git update-ref "refs/bisect/$tag" "$rev" || exit
|
2008-02-12 20:50:57 +01:00
|
|
|
echo "# $state: $(git show-branch $rev)" >>"$GIT_DIR/BISECT_LOG"
|
2008-07-11 18:01:29 +02:00
|
|
|
test -n "$nolog" || echo "git bisect $state $rev" >>"$GIT_DIR/BISECT_LOG"
|
2007-10-24 07:01:05 +02:00
|
|
|
}
|
|
|
|
|
2007-10-24 07:01:21 +02: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 19:08:20 +02:00
|
|
|
bisect_autostart
|
2007-10-24 07:01:21 +02:00
|
|
|
state=$1
|
|
|
|
case "$#,$state" in
|
|
|
|
0,*)
|
|
|
|
die "Please call 'bisect_state' with at least one argument." ;;
|
|
|
|
1,bad|1,good|1,skip)
|
|
|
|
rev=$(git rev-parse --verify HEAD) ||
|
|
|
|
die "Bad rev input: HEAD"
|
|
|
|
bisect_write "$state" "$rev" ;;
|
2008-04-12 07:53:59 +02:00
|
|
|
2,bad|*,good|*,skip)
|
2007-10-24 07:01:21 +02:00
|
|
|
shift
|
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 05:41:45 +02:00
|
|
|
eval=''
|
2008-04-12 07:53:59 +02:00
|
|
|
for rev in "$@"
|
2007-10-24 07:01:21 +02:00
|
|
|
do
|
2008-04-12 11:17:36 +02:00
|
|
|
sha=$(git rev-parse --verify "$rev^{commit}") ||
|
2008-04-12 07:53:59 +02:00
|
|
|
die "Bad rev input: $rev"
|
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 05:41:45 +02:00
|
|
|
eval="$eval bisect_write '$state' '$sha'; "
|
|
|
|
done
|
|
|
|
eval "$eval" ;;
|
2008-04-12 07:53:59 +02:00
|
|
|
*,bad)
|
|
|
|
die "'git bisect bad' can take only one argument." ;;
|
2005-08-30 21:45:41 +02: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 19:08:20 +02:00
|
|
|
esac
|
2007-10-22 07:48:36 +02: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 19:08:20 +02:00
|
|
|
bisect_next_check() {
|
2007-04-06 08:27:44 +02:00
|
|
|
missing_good= missing_bad=
|
|
|
|
git show-ref -q --verify refs/bisect/bad || missing_bad=t
|
|
|
|
test -n "$(git for-each-ref "refs/bisect/good-*")" || missing_good=t
|
2007-04-06 07:51:14 +02:00
|
|
|
|
2007-04-06 08:27:44 +02:00
|
|
|
case "$missing_good,$missing_bad,$1" in
|
|
|
|
,,*)
|
|
|
|
: have both good and bad - ok
|
|
|
|
;;
|
|
|
|
*,)
|
|
|
|
# do not have both but not asked to fail - just report.
|
|
|
|
false
|
|
|
|
;;
|
|
|
|
t,,good)
|
|
|
|
# have bad but not good. we could bisect although
|
|
|
|
# this is less optimum.
|
|
|
|
echo >&2 'Warning: bisecting only with a bad commit.'
|
|
|
|
if test -t 0
|
|
|
|
then
|
|
|
|
printf >&2 'Are you sure [Y/n]? '
|
|
|
|
case "$(read yesno)" in [Nn]*) exit 1 ;; esac
|
|
|
|
fi
|
|
|
|
: bisect without good...
|
|
|
|
;;
|
[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 19:08:20 +02:00
|
|
|
*)
|
2007-04-06 08:27:44 +02:00
|
|
|
THEN=''
|
2008-05-28 18:57:02 +02:00
|
|
|
test -s "$GIT_DIR/BISECT_START" || {
|
2007-04-06 08:27:44 +02:00
|
|
|
echo >&2 'You need to start by "git bisect start".'
|
|
|
|
THEN='then '
|
|
|
|
}
|
|
|
|
echo >&2 'You '$THEN'need to give me at least one good' \
|
|
|
|
'and one bad revisions.'
|
|
|
|
echo >&2 '(You can use "git bisect bad" and' \
|
|
|
|
'"git bisect good" for that.)'
|
|
|
|
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 19:08:20 +02:00
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
bisect_auto_next() {
|
2005-09-17 22:51:03 +02: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 19:08:20 +02:00
|
|
|
}
|
|
|
|
|
2008-05-07 23:54:28 +02:00
|
|
|
eval_rev_list() {
|
|
|
|
_eval="$1"
|
|
|
|
|
|
|
|
eval $_eval
|
|
|
|
res=$?
|
|
|
|
|
|
|
|
if [ $res -ne 0 ]; then
|
|
|
|
echo >&2 "'git rev-list --bisect-vars' failed:"
|
|
|
|
echo >&2 "maybe you mistake good and bad revs?"
|
|
|
|
exit $res
|
|
|
|
fi
|
|
|
|
|
|
|
|
return $res
|
|
|
|
}
|
|
|
|
|
2007-10-22 07:48:36 +02:00
|
|
|
filter_skipped() {
|
|
|
|
_eval="$1"
|
|
|
|
_skip="$2"
|
|
|
|
|
|
|
|
if [ -z "$_skip" ]; then
|
2008-05-07 23:54:28 +02:00
|
|
|
eval_rev_list "$_eval"
|
2007-10-22 07:48:36 +02:00
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Let's parse the output of:
|
|
|
|
# "git rev-list --bisect-vars --bisect-all ..."
|
2008-05-07 23:54:28 +02:00
|
|
|
eval_rev_list "$_eval" | while read hash line
|
2007-10-22 07:48:36 +02:00
|
|
|
do
|
|
|
|
case "$VARS,$FOUND,$TRIED,$hash" in
|
|
|
|
# We display some vars.
|
|
|
|
1,*,*,*) echo "$hash $line" ;;
|
|
|
|
|
|
|
|
# Split line.
|
|
|
|
,*,*,---*) ;;
|
|
|
|
|
|
|
|
# We had nothing to search.
|
|
|
|
,,,bisect_rev*)
|
|
|
|
echo "bisect_rev="
|
|
|
|
VARS=1
|
|
|
|
;;
|
|
|
|
|
|
|
|
# We did not find a good bisect rev.
|
|
|
|
# This should happen only if the "bad"
|
|
|
|
# commit is also a "skip" commit.
|
|
|
|
,,*,bisect_rev*)
|
|
|
|
echo "bisect_rev=$TRIED"
|
|
|
|
VARS=1
|
|
|
|
;;
|
|
|
|
|
|
|
|
# We are searching.
|
|
|
|
,,*,*)
|
|
|
|
TRIED="${TRIED:+$TRIED|}$hash"
|
|
|
|
case "$_skip" in
|
|
|
|
*$hash*) ;;
|
|
|
|
*)
|
|
|
|
echo "bisect_rev=$hash"
|
|
|
|
echo "bisect_tried=\"$TRIED\""
|
|
|
|
FOUND=1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
|
|
|
|
# We have already found a rev to be tested.
|
|
|
|
,1,*,bisect_rev*) VARS=1 ;;
|
|
|
|
,1,*,*) ;;
|
|
|
|
|
|
|
|
# ???
|
|
|
|
*) die "filter_skipped error " \
|
|
|
|
"VARS: '$VARS' " \
|
|
|
|
"FOUND: '$FOUND' " \
|
|
|
|
"TRIED: '$TRIED' " \
|
|
|
|
"hash: '$hash' " \
|
|
|
|
"line: '$line'"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
exit_if_skipped_commits () {
|
|
|
|
_tried=$1
|
|
|
|
if expr "$_tried" : ".*[|].*" > /dev/null ; then
|
|
|
|
echo "There are only 'skip'ped commit left to test."
|
|
|
|
echo "The first bad commit could be any of:"
|
2007-11-15 09:39:57 +01:00
|
|
|
echo "$_tried" | tr '[|]' '[\012]'
|
2007-10-22 07:48:36 +02:00
|
|
|
echo "We cannot bisect more!"
|
|
|
|
exit 2
|
|
|
|
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 19:08:20 +02:00
|
|
|
bisect_next() {
|
2007-10-22 07:48:23 +02: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 19:08:20 +02:00
|
|
|
bisect_autostart
|
2007-04-06 08:27:44 +02:00
|
|
|
bisect_next_check good
|
|
|
|
|
2007-10-22 07:48:36 +02:00
|
|
|
skip=$(git for-each-ref --format='%(objectname)' \
|
tr portability fixes
Specifying character ranges in tr differs between System V
and POSIX. In System V, brackets are required (e.g.,
'[A-Z]'), whereas in POSIX they are not.
We can mostly get around this by just using the bracket form
for both sets, as in:
tr '[A-Z] '[a-z]'
in which case POSIX interpets this as "'[' becomes '['",
which is OK.
However, this doesn't work with multiple sequences, like:
# rot13
tr '[A-Z][a-z]' '[N-Z][A-M][n-z][a-m]'
where the POSIX version does not behave the same as the
System V version. In this case, we must simply enumerate the
sequence.
This patch fixes problematic uses of tr in git scripts and
test scripts in one of three ways:
- if a single sequence, make sure it uses brackets
- if multiple sequences, enumerate
- if extra brackets (e.g., tr '[A]' 'a'), eliminate
brackets
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-03-12 22:29:57 +01:00
|
|
|
"refs/bisect/skip-*" | tr '\012' ' ') || exit
|
2007-10-22 07:48:36 +02:00
|
|
|
|
|
|
|
BISECT_OPT=''
|
|
|
|
test -n "$skip" && BISECT_OPT='--bisect-all'
|
|
|
|
|
2007-07-03 07:52:14 +02:00
|
|
|
bad=$(git rev-parse --verify refs/bisect/bad) &&
|
2007-04-06 08:27:44 +02:00
|
|
|
good=$(git for-each-ref --format='^%(objectname)' \
|
tr portability fixes
Specifying character ranges in tr differs between System V
and POSIX. In System V, brackets are required (e.g.,
'[A-Z]'), whereas in POSIX they are not.
We can mostly get around this by just using the bracket form
for both sets, as in:
tr '[A-Z] '[a-z]'
in which case POSIX interpets this as "'[' becomes '['",
which is OK.
However, this doesn't work with multiple sequences, like:
# rot13
tr '[A-Z][a-z]' '[N-Z][A-M][n-z][a-m]'
where the POSIX version does not behave the same as the
System V version. In this case, we must simply enumerate the
sequence.
This patch fixes problematic uses of tr in git scripts and
test scripts in one of three ways:
- if a single sequence, make sure it uses brackets
- if multiple sequences, enumerate
- if extra brackets (e.g., tr '[A]' 'a'), eliminate
brackets
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-03-12 22:29:57 +01:00
|
|
|
"refs/bisect/good-*" | tr '\012' ' ') &&
|
2007-10-22 07:48:36 +02:00
|
|
|
eval="git rev-list --bisect-vars $BISECT_OPT $good $bad --" &&
|
2007-04-06 08:27:44 +02:00
|
|
|
eval="$eval $(cat "$GIT_DIR/BISECT_NAMES")" &&
|
2007-10-22 07:48:36 +02:00
|
|
|
eval=$(filter_skipped "$eval" "$skip") &&
|
2007-04-06 08:27:44 +02:00
|
|
|
eval "$eval" || exit
|
|
|
|
|
|
|
|
if [ -z "$bisect_rev" ]; then
|
|
|
|
echo "$bad was both good and bad"
|
|
|
|
exit 1
|
2005-08-30 20:04:39 +02:00
|
|
|
fi
|
2007-04-06 08:27:44 +02:00
|
|
|
if [ "$bisect_rev" = "$bad" ]; then
|
2007-10-22 07:48:36 +02:00
|
|
|
exit_if_skipped_commits "$bisect_tried"
|
2007-04-06 08:27:44 +02:00
|
|
|
echo "$bisect_rev is first bad commit"
|
2007-07-03 07:52:14 +02:00
|
|
|
git diff-tree --pretty $bisect_rev
|
2007-04-06 08:27:44 +02:00
|
|
|
exit 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 19:08:20 +02:00
|
|
|
fi
|
2007-04-06 08:27:44 +02:00
|
|
|
|
2007-10-22 07:48:36 +02:00
|
|
|
# We should exit here only if the "bad"
|
|
|
|
# commit is also a "skip" commit (see above).
|
|
|
|
exit_if_skipped_commits "$bisect_rev"
|
|
|
|
|
2007-04-06 08:27:44 +02:00
|
|
|
echo "Bisecting: $bisect_nr revisions left to test after this"
|
2008-05-23 01:28:57 +02:00
|
|
|
git checkout -q "$bisect_rev" || exit
|
2007-07-03 07:52:14 +02:00
|
|
|
git show-branch "$bisect_rev"
|
[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 19:08:20 +02:00
|
|
|
}
|
|
|
|
|
2005-08-30 21:45:41 +02:00
|
|
|
bisect_visualize() {
|
|
|
|
bisect_next_check fail
|
2007-12-07 11:25:34 +01:00
|
|
|
|
|
|
|
if test $# = 0
|
|
|
|
then
|
2008-02-14 13:29:58 +01:00
|
|
|
case "${DISPLAY+set}${MSYSTEM+set}${SECURITYSESSIONID+set}" in
|
2007-12-07 11:25:34 +01:00
|
|
|
'') set git log ;;
|
2008-02-14 13:29:58 +01:00
|
|
|
set*) set gitk ;;
|
2007-12-07 11:25:34 +01:00
|
|
|
esac
|
|
|
|
else
|
|
|
|
case "$1" in
|
|
|
|
git*|tig) ;;
|
|
|
|
-*) set git log "$@" ;;
|
|
|
|
*) set git "$@" ;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
2007-11-17 14:35:25 +01:00
|
|
|
not=$(git for-each-ref --format='%(refname)' "refs/bisect/good-*")
|
2007-12-07 11:25:34 +01:00
|
|
|
eval '"$@"' refs/bisect/bad --not $not -- $(cat "$GIT_DIR/BISECT_NAMES")
|
2005-08-30 21:45:41 +02: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 19:08:20 +02:00
|
|
|
bisect_reset() {
|
2008-05-28 18:57:02 +02:00
|
|
|
test -s "$GIT_DIR/BISECT_START" || {
|
2007-11-20 06:39:53 +01:00
|
|
|
echo "We are not bisecting."
|
|
|
|
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 19:08:20 +02:00
|
|
|
case "$#" in
|
2008-05-28 18:57:02 +02:00
|
|
|
0) branch=$(cat "$GIT_DIR/BISECT_START") ;;
|
2007-10-24 07:01:13 +02:00
|
|
|
1) git show-ref --verify --quiet -- "refs/heads/$1" ||
|
|
|
|
die "$1 does not seem to be a valid branch"
|
[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 19:08:20 +02:00
|
|
|
branch="$1" ;;
|
2007-10-22 07:48:23 +02: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 19:08:20 +02:00
|
|
|
usage ;;
|
|
|
|
esac
|
2008-05-23 00:38:59 +02:00
|
|
|
git checkout "$branch" && bisect_clean_state
|
2005-09-11 00:18:31 +02:00
|
|
|
}
|
|
|
|
|
2007-04-04 07:12:02 +02:00
|
|
|
bisect_clean_state() {
|
2007-11-15 08:18:07 +01:00
|
|
|
# There may be some refs packed during bisection.
|
2008-05-23 01:28:57 +02:00
|
|
|
git for-each-ref --format='%(refname) %(objectname)' refs/bisect/\* |
|
2007-11-15 08:18:07 +01:00
|
|
|
while read ref hash
|
|
|
|
do
|
2008-05-28 18:57:02 +02:00
|
|
|
git update-ref -d $ref $hash || exit
|
2007-11-15 08:18:07 +01:00
|
|
|
done
|
2008-05-28 18:57:02 +02:00
|
|
|
rm -f "$GIT_DIR/BISECT_LOG" &&
|
|
|
|
rm -f "$GIT_DIR/BISECT_NAMES" &&
|
|
|
|
rm -f "$GIT_DIR/BISECT_RUN" &&
|
2008-05-23 00:38:59 +02:00
|
|
|
# Cleanup head-name if it got left by an old version of git-bisect
|
2008-05-28 18:57:02 +02:00
|
|
|
rm -f "$GIT_DIR/head-name" &&
|
|
|
|
|
|
|
|
rm -f "$GIT_DIR/BISECT_START"
|
2007-04-04 07:12:02 +02:00
|
|
|
}
|
|
|
|
|
2005-09-11 00:18:31 +02:00
|
|
|
bisect_replay () {
|
2007-10-24 07:01:13 +02:00
|
|
|
test -r "$1" || die "cannot read $1 for replaying"
|
2005-09-11 00:18:31 +02:00
|
|
|
bisect_reset
|
2008-07-11 18:01:29 +02:00
|
|
|
while read git bisect command rev
|
2005-09-11 00:18:31 +02:00
|
|
|
do
|
2008-07-11 18:01:29 +02:00
|
|
|
test "$git $bisect" = "git bisect" -o "$git" = "git-bisect" || continue
|
|
|
|
if test "$git" = "git-bisect"; then
|
|
|
|
rev="$command"
|
|
|
|
command="$bisect"
|
|
|
|
fi
|
2005-09-11 00:18:31 +02:00
|
|
|
case "$command" in
|
|
|
|
start)
|
2005-11-28 02:42:05 +01:00
|
|
|
cmd="bisect_start $rev"
|
2007-10-24 07:01:13 +02:00
|
|
|
eval "$cmd" ;;
|
|
|
|
good|bad|skip)
|
|
|
|
bisect_write "$command" "$rev" ;;
|
2005-09-11 00:18:31 +02:00
|
|
|
*)
|
2007-10-24 07:01:13 +02:00
|
|
|
die "?? what are you talking about?" ;;
|
2005-09-11 00:18:31 +02:00
|
|
|
esac
|
|
|
|
done <"$1"
|
|
|
|
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 19:08:20 +02:00
|
|
|
}
|
|
|
|
|
2007-03-23 08:49:59 +01:00
|
|
|
bisect_run () {
|
2007-03-27 06:49:57 +02:00
|
|
|
bisect_next_check fail
|
|
|
|
|
2007-03-23 08:49:59 +01:00
|
|
|
while true
|
|
|
|
do
|
|
|
|
echo "running $@"
|
|
|
|
"$@"
|
|
|
|
res=$?
|
|
|
|
|
|
|
|
# Check for really bad run error.
|
|
|
|
if [ $res -lt 0 -o $res -ge 128 ]; then
|
|
|
|
echo >&2 "bisect run failed:"
|
|
|
|
echo >&2 "exit code $res from '$@' is < 0 or >= 128"
|
|
|
|
exit $res
|
|
|
|
fi
|
|
|
|
|
2007-10-24 07:01:21 +02:00
|
|
|
# Find current state depending on run success or failure.
|
2007-10-26 05:39:37 +02:00
|
|
|
# A special exit code of 125 means cannot test.
|
|
|
|
if [ $res -eq 125 ]; then
|
|
|
|
state='skip'
|
|
|
|
elif [ $res -gt 0 ]; then
|
2007-10-24 07:01:21 +02:00
|
|
|
state='bad'
|
2007-03-23 08:49:59 +01:00
|
|
|
else
|
2007-10-24 07:01:21 +02:00
|
|
|
state='good'
|
2007-03-23 08:49:59 +01:00
|
|
|
fi
|
|
|
|
|
2007-10-24 07:01:21 +02:00
|
|
|
# We have to use a subshell because "bisect_state" can exit.
|
|
|
|
( bisect_state $state > "$GIT_DIR/BISECT_RUN" )
|
2007-03-23 08:49:59 +01:00
|
|
|
res=$?
|
|
|
|
|
|
|
|
cat "$GIT_DIR/BISECT_RUN"
|
|
|
|
|
2007-10-26 05:39:37 +02:00
|
|
|
if grep "first bad commit could be any of" "$GIT_DIR/BISECT_RUN" \
|
|
|
|
> /dev/null; then
|
|
|
|
echo >&2 "bisect run cannot continue any more"
|
|
|
|
exit $res
|
|
|
|
fi
|
|
|
|
|
2007-03-23 08:49:59 +01:00
|
|
|
if [ $res -ne 0 ]; then
|
|
|
|
echo >&2 "bisect run failed:"
|
2007-10-24 07:01:21 +02:00
|
|
|
echo >&2 "'bisect_state $state' exited with error code $res"
|
2007-03-23 08:49:59 +01:00
|
|
|
exit $res
|
|
|
|
fi
|
|
|
|
|
|
|
|
if grep "is first bad commit" "$GIT_DIR/BISECT_RUN" > /dev/null; then
|
|
|
|
echo "bisect run success"
|
|
|
|
exit 0;
|
|
|
|
fi
|
|
|
|
|
|
|
|
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 19:08:20 +02:00
|
|
|
case "$#" in
|
|
|
|
0)
|
|
|
|
usage ;;
|
|
|
|
*)
|
|
|
|
cmd="$1"
|
|
|
|
shift
|
|
|
|
case "$cmd" in
|
2008-04-11 05:55:21 +02:00
|
|
|
help)
|
|
|
|
git bisect -h ;;
|
[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 19:08:20 +02:00
|
|
|
start)
|
|
|
|
bisect_start "$@" ;;
|
2007-10-24 07:01:21 +02:00
|
|
|
bad|good|skip)
|
|
|
|
bisect_state "$cmd" "$@" ;;
|
[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 19:08:20 +02:00
|
|
|
next)
|
|
|
|
# Not sure we want "next" at the UI level anymore.
|
|
|
|
bisect_next "$@" ;;
|
2007-12-07 11:25:34 +01:00
|
|
|
visualize|view)
|
2005-08-30 21:45:41 +02:00
|
|
|
bisect_visualize "$@" ;;
|
[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 19:08:20 +02:00
|
|
|
reset)
|
|
|
|
bisect_reset "$@" ;;
|
2005-09-11 00:18:31 +02:00
|
|
|
replay)
|
|
|
|
bisect_replay "$@" ;;
|
|
|
|
log)
|
|
|
|
cat "$GIT_DIR/BISECT_LOG" ;;
|
2007-03-23 08:49:59 +01:00
|
|
|
run)
|
|
|
|
bisect_run "$@" ;;
|
[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 19:08:20 +02:00
|
|
|
*)
|
|
|
|
usage ;;
|
|
|
|
esac
|
|
|
|
esac
|