]>
Commit | Line | Data |
---|---|---|
8cc6a083 | 1 | #!/bin/sh |
d025524d | 2 | |
dbc349bb | 3 | USAGE='[help|start|bad|good|new|old|terms|skip|next|reset|visualize|view|replay|log|run]' |
243a60fb | 4 | LONG_USAGE='git bisect help |
6021be86 | 5 | print this long help message. |
ef4d9f8a | 6 | git bisect start [--term-{new,bad}=<term> --term-{old,good}=<term>] |
6028f5f6 | 7 | [--no-checkout] [--first-parent] [<bad> [<good>...]] [--] [<pathspec>...] |
6021be86 | 8 | reset bisect state and start bisection. |
21e5cfd8 AD |
9 | git bisect (bad|new) [<rev>] |
10 | mark <rev> a known-bad revision/ | |
11 | a revision after change in a given property. | |
12 | git bisect (good|old) [<rev>...] | |
13 | mark <rev>... known-good revisions/ | |
14 | revisions before change in a given property. | |
21b55e33 MM |
15 | git bisect terms [--term-good | --term-bad] |
16 | show the terms used for old and new commits (default: bad, good) | |
5413812f | 17 | git bisect skip [(<rev>|<range>)...] |
6021be86 | 18 | mark <rev>... untestable revisions. |
38a47fd6 | 19 | git bisect next |
6021be86 | 20 | find next bisection to test and check it out. |
6b87ce23 | 21 | git bisect reset [<commit>] |
6021be86 | 22 | finish bisection search and go back to commit. |
dbc349bb | 23 | git bisect (visualize|view) |
6021be86 | 24 | show bisect status in gitk. |
38a47fd6 | 25 | git bisect replay <logfile> |
6021be86 | 26 | replay bisection log. |
38a47fd6 | 27 | git bisect log |
6021be86 | 28 | show bisect log. |
38a47fd6 | 29 | git bisect run <cmd>... |
6021be86 | 30 | use <cmd>... to automatically bisect. |
243a60fb CC |
31 | |
32 | Please use "git help bisect" to get the full man page.' | |
d025524d | 33 | |
8f321a39 | 34 | OPTIONS_SPEC= |
ae2b0f15 | 35 | . git-sh-setup |
8cc6a083 | 36 | |
ce32660e JS |
37 | _x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]' |
38 | _x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40" | |
43f9d9f3 AD |
39 | TERM_BAD=bad |
40 | TERM_GOOD=good | |
ce32660e | 41 | |
cc9f24d0 | 42 | bisect_visualize() { |
129a6cf3 | 43 | git bisect--helper --bisect-next-check $TERM_GOOD $TERM_BAD fail || exit |
235997c9 JH |
44 | |
45 | if test $# = 0 | |
46 | then | |
c4e4644e | 47 | if test -n "${DISPLAY+set}${SESSIONNAME+set}${MSYSTEM+set}${SECURITYSESSIONID+set}" && |
43b8ff4b | 48 | type gitk >/dev/null 2>&1 |
eef12a9a | 49 | then |
c4e4644e JK |
50 | set gitk |
51 | else | |
52 | set git log | |
53 | fi | |
235997c9 JH |
54 | else |
55 | case "$1" in | |
56 | git*|tig) ;; | |
57 | -*) set git log "$@" ;; | |
58 | *) set git "$@" ;; | |
59 | esac | |
60 | fi | |
61 | ||
fc13aa3d | 62 | eval '"$@"' --bisect -- $(cat "$GIT_DIR/BISECT_NAMES") |
cc9f24d0 JH |
63 | } |
64 | ||
a17c4101 | 65 | bisect_run () { |
129a6cf3 | 66 | git bisect--helper --bisect-next-check $TERM_GOOD $TERM_BAD fail || exit |
6021be86 | 67 | |
fecd2dd3 SB |
68 | test -n "$*" || die "$(gettext "bisect run failed: no command provided.")" |
69 | ||
6021be86 JS |
70 | while true |
71 | do | |
72 | command="$@" | |
3145b1a2 | 73 | eval_gettextln "running \$command" |
6021be86 JS |
74 | "$@" |
75 | res=$? | |
76 | ||
77 | # Check for really bad run error. | |
eef12a9a JS |
78 | if [ $res -lt 0 -o $res -ge 128 ] |
79 | then | |
3145b1a2 JS |
80 | eval_gettextln "bisect run failed: |
81 | exit code \$res from '\$command' is < 0 or >= 128" >&2 | |
6021be86 JS |
82 | exit $res |
83 | fi | |
84 | ||
85 | # Find current state depending on run success or failure. | |
86 | # A special exit code of 125 means cannot test. | |
eef12a9a JS |
87 | if [ $res -eq 125 ] |
88 | then | |
6021be86 | 89 | state='skip' |
eef12a9a JS |
90 | elif [ $res -gt 0 ] |
91 | then | |
43f9d9f3 | 92 | state="$TERM_BAD" |
6021be86 | 93 | else |
43f9d9f3 | 94 | state="$TERM_GOOD" |
6021be86 JS |
95 | fi |
96 | ||
27257bc4 | 97 | git bisect--helper --bisect-state $state >"$GIT_DIR/BISECT_RUN" |
6021be86 JS |
98 | res=$? |
99 | ||
100 | cat "$GIT_DIR/BISECT_RUN" | |
101 | ||
43f9d9f3 | 102 | if sane_grep "first $TERM_BAD commit could be any of" "$GIT_DIR/BISECT_RUN" \ |
305a233c | 103 | >/dev/null |
eef12a9a | 104 | then |
3145b1a2 | 105 | gettextln "bisect run cannot continue any more" >&2 |
6021be86 JS |
106 | exit $res |
107 | fi | |
108 | ||
eef12a9a JS |
109 | if [ $res -ne 0 ] |
110 | then | |
3145b1a2 | 111 | eval_gettextln "bisect run failed: |
27257bc4 | 112 | 'bisect-state \$state' exited with error code \$res" >&2 |
6021be86 JS |
113 | exit $res |
114 | fi | |
a17c4101 | 115 | |
43f9d9f3 | 116 | if sane_grep "is the first $TERM_BAD commit" "$GIT_DIR/BISECT_RUN" >/dev/null |
eef12a9a | 117 | then |
3145b1a2 | 118 | gettextln "bisect run success" |
6021be86 JS |
119 | exit 0; |
120 | fi | |
a17c4101 | 121 | |
6021be86 | 122 | done |
a17c4101 CC |
123 | } |
124 | ||
cb46d630 AD |
125 | get_terms () { |
126 | if test -s "$GIT_DIR/BISECT_TERMS" | |
127 | then | |
128 | { | |
129 | read TERM_BAD | |
130 | read TERM_GOOD | |
131 | } <"$GIT_DIR/BISECT_TERMS" | |
132 | fi | |
133 | } | |
134 | ||
8cc6a083 LT |
135 | case "$#" in |
136 | 0) | |
6021be86 | 137 | usage ;; |
8cc6a083 | 138 | *) |
6021be86 | 139 | cmd="$1" |
cb46d630 | 140 | get_terms |
6021be86 JS |
141 | shift |
142 | case "$cmd" in | |
143 | help) | |
144 | git bisect -h ;; | |
145 | start) | |
88ad372f | 146 | git bisect--helper --bisect-start "$@" ;; |
21e5cfd8 | 147 | bad|good|new|old|"$TERM_BAD"|"$TERM_GOOD") |
27257bc4 | 148 | git bisect--helper --bisect-state "$cmd" "$@" ;; |
6021be86 | 149 | skip) |
e4c7b337 | 150 | git bisect--helper --bisect-skip "$@" || exit;; |
6021be86 JS |
151 | next) |
152 | # Not sure we want "next" at the UI level anymore. | |
517ecb31 | 153 | git bisect--helper --bisect-next "$@" || exit ;; |
6021be86 JS |
154 | visualize|view) |
155 | bisect_visualize "$@" ;; | |
156 | reset) | |
5e82c3dd | 157 | git bisect--helper --bisect-reset "$@" ;; |
6021be86 | 158 | replay) |
2b1fd947 | 159 | git bisect--helper --bisect-replay "$@" || exit;; |
6021be86 | 160 | log) |
97d5ba6a | 161 | git bisect--helper --bisect-log || exit ;; |
6021be86 JS |
162 | run) |
163 | bisect_run "$@" ;; | |
21b55e33 | 164 | terms) |
450ebb73 | 165 | git bisect--helper --bisect-terms "$@" || exit;; |
6021be86 JS |
166 | *) |
167 | usage ;; | |
168 | esac | |
8cc6a083 | 169 | esac |