1#!/bin/sh
2
3set -e
4
5if test "bisect-create" = "`basename $0`" ; then
6    echo tools/ffbisect created
7    git show master:tools/bisect-create > tools/ffbisect
8    chmod u+x tools/ffbisect
9    exit 1
10fi
11
12if ! git show master:tools/bisect-create | diff - tools/ffbisect > /dev/null ; then
13    echo updating tools/ffbisect script to HEAD.
14    git show master:tools/bisect-create > tools/ffbisect
15    chmod u+x tools/ffbisect
16    tools/ffbisect $*
17    exit 0
18fi
19
20case "$1" in
21    need)
22        case $2 in
23            ffmpeg|ffplay|ffprobe)
24                echo $2.c >> tools/bisect.need
25            ;;
26        esac
27    ;;
28    start|reset)
29        echo . > tools/bisect.need
30        git bisect $*
31    ;;
32    skip)
33        git bisect $*
34    ;;
35    good|bad)
36        git bisect $*
37
38        until ls `cat tools/bisect.need` > /dev/null 2> /dev/null; do
39            git bisect skip || break
40        done
41    ;;
42    run)
43       shift # remove "run" from arguments
44       git bisect run sh -c "ls \`cat tools/bisect.need\` > /dev/null 2> /dev/null || exit 125; \"\$@\"" sh "$@"
45    ;;
46esac
47