bisect everything, from initial commit
Asked Answered
C

1

21

Say I have a small project with a very fast test script, and I just want to bisect everything, from the initial commit to the curret commit. How can I do that?

To clarify, I don't want to waste time identifying a commit that is good and a commit that is bad, so I'm looking for a quick way to mark the latest commit as bad, and the initial commit as good.

Coed answered 9/7, 2014 at 15:32 Comment(0)
C
12
git bisect start
git bisect good
git bisect bad `git rev-list --max-parents=0 HEAD`
git bisect run ./test.sh

Or incorporate these commands into an alias, e.g.:

bisect-all = !git bisect start && git bisect bad &&\
        git bisect good `git rev-list --max-parents=0 --first-parent HEAD`

And then just use git bisect-all, git bisect run ./test.sh.

Creating an alias to handle the whole process is slightly more complicated:

quick-bisect = !sh -c 'git bisect start && git bisect bad &&\
        git bisect good `git rev-list --max-parents=0 --first-parent HEAD` &&\
        git bisect run "$@" && git bisect reset' -

But with that, you can simply run git quick-bisect ./test.sh.


If you're using a version of git older than 1.7.4.2, you won't have the --max-parents option, so will need to use something like git rev-list HEAD | tail -n 1 instead.

Coed answered 9/7, 2014 at 15:32 Comment(3)
maybe add --first-parent to the rev-list to avoid multiple-root trouble when e.g. projects get merged, and quote the params, "$@", to avoid unwanted word splitting?Heinrike
@jthill: Thanks, I added --first-parent. It took me a while to figure out what you meant about unwanted word splitting, but even with quotes "$@", words are split: git quick-bisect ./test.sh "ONE TWO THREE" runs ./test.sh ONE TWO THREE. What's going on?Coed
If its in an alias I think you might need to escape the quotes, not sure otherwise.Heinrike

© 2022 - 2024 — McMap. All rights reserved.