From 8fe26f4481f274a6c752a6c13ac5da0460dbd1b6 Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Mon, 22 Oct 2007 07:48:23 +0200 Subject: Bisect: fix some white spaces and empty lines breakages. Signed-off-by: Christian Couder Signed-off-by: Shawn O. Pearce --- git-bisect.sh | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'git-bisect.sh') diff --git a/git-bisect.sh b/git-bisect.sh index 388887a556..436ccf66ff 100755 --- a/git-bisect.sh +++ b/git-bisect.sh @@ -64,7 +64,7 @@ bisect_start() { branch=`cat "$GIT_DIR/head-name"` else branch=master - fi + fi git checkout $branch || exit ;; refs/heads/*) @@ -95,11 +95,11 @@ bisect_start() { arg="$1" case "$arg" in --) - shift + shift break ;; *) - rev=$(git rev-parse --verify "$arg^{commit}" 2>/dev/null) || { + rev=$(git rev-parse --verify "$arg^{commit}" 2>/dev/null) || { test $has_double_dash -eq 1 && die "'$arg' does not appear to be a valid revision" break @@ -110,10 +110,10 @@ bisect_start() { else bisect_write_good "$rev" fi - shift + shift ;; esac - done + done sq "$@" >"$GIT_DIR/BISECT_NAMES" echo "git-bisect start$orig_args" >>"$GIT_DIR/BISECT_LOG" @@ -143,7 +143,7 @@ bisect_write_bad() { bisect_good() { bisect_autostart - case "$#" in + case "$#" in 0) revs=$(git rev-parse --verify HEAD) || exit ;; *) revs=$(git rev-parse --revs-only --no-flags "$@") && test '' != "$revs" || die "Bad rev input: $@" ;; @@ -153,7 +153,6 @@ bisect_good() { rev=$(git rev-parse --verify "$rev^{commit}") || exit bisect_write_good "$rev" echo "git-bisect good $rev" >>"$GIT_DIR/BISECT_LOG" - done bisect_auto_next } @@ -207,7 +206,7 @@ bisect_auto_next() { } bisect_next() { - case "$#" in 0) ;; *) usage ;; esac + case "$#" in 0) ;; *) usage ;; esac bisect_autostart bisect_next_check good @@ -255,7 +254,7 @@ bisect_reset() { exit 1 } branch="$1" ;; - *) + *) usage ;; esac if git checkout "$branch"; then -- cgit v1.2.3 From 97e1c51e15d94f523c67a499ecb633b0e20324cb Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Mon, 22 Oct 2007 07:48:36 +0200 Subject: Bisect: implement "bisect skip" to mark untestable revisions. When there are some "skip"ped revisions, we add the '--bisect-all' option to "git rev-list --bisect-vars". Then we filter out the "skip"ped revisions from the result of the rev-list command, and we modify the "bisect_rev" var accordingly. We don't always use "--bisect-all" because it is slower than "--bisect-vars" or "--bisect". When we cannot find for sure the first bad commit because of "skip"ped commits, we print the hash of each possible first bad commit and then we exit with code 2. Signed-off-by: Christian Couder Signed-off-by: Shawn O. Pearce --- git-bisect.sh | 125 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 119 insertions(+), 6 deletions(-) (limited to 'git-bisect.sh') diff --git a/git-bisect.sh b/git-bisect.sh index 436ccf66ff..cd46190302 100755 --- a/git-bisect.sh +++ b/git-bisect.sh @@ -17,6 +17,8 @@ git bisect replay replay bisection log. git bisect log show bisect log. +git bisect skip [...] + mark ... untestable revisions. git bisect run ... use ... to automatically bisect.' @@ -163,6 +165,28 @@ bisect_write_good() { echo "# good: "$(git show-branch $rev) >>"$GIT_DIR/BISECT_LOG" } +bisect_skip() { + bisect_autostart + case "$#" in + 0) revs=$(git rev-parse --verify HEAD) || exit ;; + *) revs=$(git rev-parse --revs-only --no-flags "$@") && + test '' != "$revs" || die "Bad rev input: $@" ;; + esac + for rev in $revs + do + rev=$(git rev-parse --verify "$rev^{commit}") || exit + bisect_write_skip "$rev" + echo "git-bisect skip $rev" >>"$GIT_DIR/BISECT_LOG" + done + bisect_auto_next +} + +bisect_write_skip() { + rev="$1" + echo "$rev" >"$GIT_DIR/refs/bisect/skip-$rev" + echo "# skip: "$(git show-branch $rev) >>"$GIT_DIR/BISECT_LOG" +} + bisect_next_check() { missing_good= missing_bad= git show-ref -q --verify refs/bisect/bad || missing_bad=t @@ -205,17 +229,97 @@ bisect_auto_next() { bisect_next_check && bisect_next || : } +filter_skipped() { + _eval="$1" + _skip="$2" + + if [ -z "$_skip" ]; then + eval $_eval + return + fi + + # Let's parse the output of: + # "git rev-list --bisect-vars --bisect-all ..." + eval $_eval | while read hash line + 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:" + echo "$_tried" | sed -e 's/[|]/\n/g' + echo "We cannot bisect more!" + exit 2 + fi +} + bisect_next() { case "$#" in 0) ;; *) usage ;; esac bisect_autostart bisect_next_check good + skip=$(git for-each-ref --format='%(objectname)' \ + "refs/bisect/skip-*" | tr '[\012]' ' ') || exit + + BISECT_OPT='' + test -n "$skip" && BISECT_OPT='--bisect-all' + bad=$(git rev-parse --verify refs/bisect/bad) && good=$(git for-each-ref --format='^%(objectname)' \ "refs/bisect/good-*" | tr '[\012]' ' ') && - eval="git rev-list --bisect-vars $good $bad --" && + eval="git rev-list --bisect-vars $BISECT_OPT $good $bad --" && eval="$eval $(cat "$GIT_DIR/BISECT_NAMES")" && - eval=$(eval "$eval") && + eval=$(filter_skipped "$eval" "$skip") && eval "$eval" || exit if [ -z "$bisect_rev" ]; then @@ -223,11 +327,16 @@ bisect_next() { exit 1 fi if [ "$bisect_rev" = "$bad" ]; then + exit_if_skipped_commits "$bisect_tried" echo "$bisect_rev is first bad commit" git diff-tree --pretty $bisect_rev exit 0 fi + # We should exit here only if the "bad" + # commit is also a "skip" commit (see above). + exit_if_skipped_commits "$bisect_rev" + echo "Bisecting: $bisect_nr revisions left to test after this" echo "$bisect_rev" >"$GIT_DIR/refs/heads/new-bisect" git checkout -q new-bisect || exit @@ -286,15 +395,17 @@ bisect_replay () { eval "$cmd" ;; good) - echo "$rev" >"$GIT_DIR/refs/bisect/good-$rev" - echo "# good: "$(git show-branch $rev) >>"$GIT_DIR/BISECT_LOG" + bisect_write_good "$rev" echo "git-bisect good $rev" >>"$GIT_DIR/BISECT_LOG" ;; bad) - echo "$rev" >"$GIT_DIR/refs/bisect/bad" - echo "# bad: "$(git show-branch $rev) >>"$GIT_DIR/BISECT_LOG" + bisect_write_bad "$rev" echo "git-bisect bad $rev" >>"$GIT_DIR/BISECT_LOG" ;; + skip) + bisect_write_skip "$rev" + echo "git-bisect skip $rev" >>"$GIT_DIR/BISECT_LOG" + ;; *) echo >&2 "?? what are you talking about?" exit 1 ;; @@ -362,6 +473,8 @@ case "$#" in bisect_bad "$@" ;; good) bisect_good "$@" ;; + skip) + bisect_skip "$@" ;; next) # Not sure we want "next" at the UI level anymore. bisect_next "$@" ;; -- cgit v1.2.3 From 55624f9af49733ca6ae4abc3cd21e0f9a4f9f486 Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Wed, 24 Oct 2007 07:01:05 +0200 Subject: Bisect: refactor "bisect_write_*" functions. Signed-off-by: Christian Couder Signed-off-by: Shawn O. Pearce Signed-off-by: Junio C Hamano --- git-bisect.sh | 46 ++++++++++++++++++++-------------------------- 1 file changed, 20 insertions(+), 26 deletions(-) (limited to 'git-bisect.sh') diff --git a/git-bisect.sh b/git-bisect.sh index cd46190302..82aa40433b 100755 --- a/git-bisect.sh +++ b/git-bisect.sh @@ -108,9 +108,9 @@ bisect_start() { } if [ $bad_seen -eq 0 ]; then bad_seen=1 - bisect_write_bad "$rev" + bisect_write 'bad' "$rev" else - bisect_write_good "$rev" + bisect_write 'good' "$rev" fi shift ;; @@ -122,6 +122,18 @@ bisect_start() { bisect_auto_next } +bisect_write() { + state="$1" + rev="$2" + case "$state" in + bad) tag="$state" ;; + good|skip) tag="$state"-"$rev" ;; + *) die "Bad bisect_write argument: $state" ;; + esac + echo "$rev" >"$GIT_DIR/refs/bisect/$tag" + echo "# $state: "$(git show-branch $rev) >>"$GIT_DIR/BISECT_LOG" +} + bisect_bad() { bisect_autostart case "$#" in @@ -132,17 +144,11 @@ bisect_bad() { *) usage ;; esac || exit - bisect_write_bad "$rev" + bisect_write 'bad' "$rev" echo "git-bisect bad $rev" >>"$GIT_DIR/BISECT_LOG" bisect_auto_next } -bisect_write_bad() { - rev="$1" - echo "$rev" >"$GIT_DIR/refs/bisect/bad" - echo "# bad: "$(git show-branch $rev) >>"$GIT_DIR/BISECT_LOG" -} - bisect_good() { bisect_autostart case "$#" in @@ -153,18 +159,12 @@ bisect_good() { for rev in $revs do rev=$(git rev-parse --verify "$rev^{commit}") || exit - bisect_write_good "$rev" + bisect_write 'good' "$rev" echo "git-bisect good $rev" >>"$GIT_DIR/BISECT_LOG" done bisect_auto_next } -bisect_write_good() { - rev="$1" - echo "$rev" >"$GIT_DIR/refs/bisect/good-$rev" - echo "# good: "$(git show-branch $rev) >>"$GIT_DIR/BISECT_LOG" -} - bisect_skip() { bisect_autostart case "$#" in @@ -175,18 +175,12 @@ bisect_skip() { for rev in $revs do rev=$(git rev-parse --verify "$rev^{commit}") || exit - bisect_write_skip "$rev" + bisect_write 'skip' "$rev" echo "git-bisect skip $rev" >>"$GIT_DIR/BISECT_LOG" done bisect_auto_next } -bisect_write_skip() { - rev="$1" - echo "$rev" >"$GIT_DIR/refs/bisect/skip-$rev" - echo "# skip: "$(git show-branch $rev) >>"$GIT_DIR/BISECT_LOG" -} - bisect_next_check() { missing_good= missing_bad= git show-ref -q --verify refs/bisect/bad || missing_bad=t @@ -395,15 +389,15 @@ bisect_replay () { eval "$cmd" ;; good) - bisect_write_good "$rev" + bisect_write 'good' "$rev" echo "git-bisect good $rev" >>"$GIT_DIR/BISECT_LOG" ;; bad) - bisect_write_bad "$rev" + bisect_write 'bad' "$rev" echo "git-bisect bad $rev" >>"$GIT_DIR/BISECT_LOG" ;; skip) - bisect_write_skip "$rev" + bisect_write 'skip' "$rev" echo "git-bisect skip $rev" >>"$GIT_DIR/BISECT_LOG" ;; *) -- cgit v1.2.3 From 737c74ee4219a81ebb616262579f63ce2a3f9698 Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Wed, 24 Oct 2007 07:01:13 +0200 Subject: Bisect: refactor some logging into "bisect_write". Also use "die" instead of "echo >&2 something ; exit 1". And simplify "bisect_replay". Signed-off-by: Christian Couder Signed-off-by: Shawn O. Pearce Signed-off-by: Junio C Hamano --- git-bisect.sh | 47 ++++++++++++++--------------------------------- 1 file changed, 14 insertions(+), 33 deletions(-) (limited to 'git-bisect.sh') diff --git a/git-bisect.sh b/git-bisect.sh index 82aa40433b..61a2956647 100755 --- a/git-bisect.sh +++ b/git-bisect.sh @@ -106,12 +106,11 @@ bisect_start() { die "'$arg' does not appear to be a valid revision" break } - if [ $bad_seen -eq 0 ]; then - bad_seen=1 - bisect_write 'bad' "$rev" - else - bisect_write 'good' "$rev" - fi + case $bad_seen in + 0) state='bad' ; bad_seen=1 ;; + *) state='good' ;; + esac + bisect_write "$state" "$rev" 'nolog' shift ;; esac @@ -125,6 +124,7 @@ bisect_start() { bisect_write() { state="$1" rev="$2" + nolog="$3" case "$state" in bad) tag="$state" ;; good|skip) tag="$state"-"$rev" ;; @@ -132,6 +132,7 @@ bisect_write() { esac echo "$rev" >"$GIT_DIR/refs/bisect/$tag" echo "# $state: "$(git show-branch $rev) >>"$GIT_DIR/BISECT_LOG" + test -z "$nolog" && echo "git-bisect $state $rev" >>"$GIT_DIR/BISECT_LOG" } bisect_bad() { @@ -145,7 +146,6 @@ bisect_bad() { usage ;; esac || exit bisect_write 'bad' "$rev" - echo "git-bisect bad $rev" >>"$GIT_DIR/BISECT_LOG" bisect_auto_next } @@ -160,7 +160,6 @@ bisect_good() { do rev=$(git rev-parse --verify "$rev^{commit}") || exit bisect_write 'good' "$rev" - echo "git-bisect good $rev" >>"$GIT_DIR/BISECT_LOG" done bisect_auto_next } @@ -176,7 +175,6 @@ bisect_skip() { do rev=$(git rev-parse --verify "$rev^{commit}") || exit bisect_write 'skip' "$rev" - echo "git-bisect skip $rev" >>"$GIT_DIR/BISECT_LOG" done bisect_auto_next } @@ -352,10 +350,8 @@ bisect_reset() { else branch=master fi ;; - 1) git show-ref --verify --quiet -- "refs/heads/$1" || { - echo >&2 "$1 does not seem to be a valid branch" - exit 1 - } + 1) git show-ref --verify --quiet -- "refs/heads/$1" || + die "$1 does not seem to be a valid branch" branch="$1" ;; *) usage ;; @@ -375,10 +371,7 @@ bisect_clean_state() { } bisect_replay () { - test -r "$1" || { - echo >&2 "cannot read $1 for replaying" - exit 1 - } + test -r "$1" || die "cannot read $1 for replaying" bisect_reset while read bisect command rev do @@ -386,23 +379,11 @@ bisect_replay () { case "$command" in start) cmd="bisect_start $rev" - eval "$cmd" - ;; - good) - bisect_write 'good' "$rev" - echo "git-bisect good $rev" >>"$GIT_DIR/BISECT_LOG" - ;; - bad) - bisect_write 'bad' "$rev" - echo "git-bisect bad $rev" >>"$GIT_DIR/BISECT_LOG" - ;; - skip) - bisect_write 'skip' "$rev" - echo "git-bisect skip $rev" >>"$GIT_DIR/BISECT_LOG" - ;; + eval "$cmd" ;; + good|bad|skip) + bisect_write "$command" "$rev" ;; *) - echo >&2 "?? what are you talking about?" - exit 1 ;; + die "?? what are you talking about?" ;; esac done <"$1" bisect_auto_next -- cgit v1.2.3 From 155fc795b9c613af79781ebec5fd8eda084e1636 Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Wed, 24 Oct 2007 07:01:21 +0200 Subject: Bisect: refactor "bisect_{bad,good,skip}" into "bisect_state". Signed-off-by: Christian Couder Signed-off-by: Shawn O. Pearce Signed-off-by: Junio C Hamano --- git-bisect.sh | 82 ++++++++++++++++++++++------------------------------------- 1 file changed, 31 insertions(+), 51 deletions(-) (limited to 'git-bisect.sh') diff --git a/git-bisect.sh b/git-bisect.sh index 61a2956647..f8d0099059 100755 --- a/git-bisect.sh +++ b/git-bisect.sh @@ -135,47 +135,33 @@ bisect_write() { test -z "$nolog" && echo "git-bisect $state $rev" >>"$GIT_DIR/BISECT_LOG" } -bisect_bad() { +bisect_state() { bisect_autostart - case "$#" in - 0) - rev=$(git rev-parse --verify HEAD) ;; - 1) - rev=$(git rev-parse --verify "$1^{commit}") ;; + 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" ;; + 2,bad) + rev=$(git rev-parse --verify "$2^{commit}") || + die "Bad rev input: $2" + bisect_write "$state" "$rev" ;; + *,good|*,skip) + shift + revs=$(git rev-parse --revs-only --no-flags "$@") && + test '' != "$revs" || die "Bad rev input: $@" + for rev in $revs + do + rev=$(git rev-parse --verify "$rev^{commit}") || + die "Bad rev commit: $rev^{commit}" + bisect_write "$state" "$rev" + done ;; *) usage ;; - esac || exit - bisect_write 'bad' "$rev" - bisect_auto_next -} - -bisect_good() { - bisect_autostart - case "$#" in - 0) revs=$(git rev-parse --verify HEAD) || exit ;; - *) revs=$(git rev-parse --revs-only --no-flags "$@") && - test '' != "$revs" || die "Bad rev input: $@" ;; esac - for rev in $revs - do - rev=$(git rev-parse --verify "$rev^{commit}") || exit - bisect_write 'good' "$rev" - done - bisect_auto_next -} - -bisect_skip() { - bisect_autostart - case "$#" in - 0) revs=$(git rev-parse --verify HEAD) || exit ;; - *) revs=$(git rev-parse --revs-only --no-flags "$@") && - test '' != "$revs" || die "Bad rev input: $@" ;; - esac - for rev in $revs - do - rev=$(git rev-parse --verify "$rev^{commit}") || exit - bisect_write 'skip' "$rev" - done bisect_auto_next } @@ -405,24 +391,22 @@ bisect_run () { exit $res fi - # Use "bisect_good" or "bisect_bad" - # depending on run success or failure. + # Find current state depending on run success or failure. if [ $res -gt 0 ]; then - next_bisect='bisect_bad' + state='bad' else - next_bisect='bisect_good' + state='good' fi - # We have to use a subshell because bisect_good or - # bisect_bad functions can exit. - ( $next_bisect > "$GIT_DIR/BISECT_RUN" ) + # We have to use a subshell because "bisect_state" can exit. + ( bisect_state $state > "$GIT_DIR/BISECT_RUN" ) res=$? cat "$GIT_DIR/BISECT_RUN" if [ $res -ne 0 ]; then echo >&2 "bisect run failed:" - echo >&2 "$next_bisect exited with error code $res" + echo >&2 "'bisect_state $state' exited with error code $res" exit $res fi @@ -444,12 +428,8 @@ case "$#" in case "$cmd" in start) bisect_start "$@" ;; - bad) - bisect_bad "$@" ;; - good) - bisect_good "$@" ;; - skip) - bisect_skip "$@" ;; + bad|good|skip) + bisect_state "$cmd" "$@" ;; next) # Not sure we want "next" at the UI level anymore. bisect_next "$@" ;; -- cgit v1.2.3 From 71b0251cdd2cc35a983e21d4e71285db56d2a519 Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Fri, 26 Oct 2007 05:39:37 +0200 Subject: Bisect run: "skip" current commit if script exit code is 125. This is incompatible with previous versions because an exit code of 125 used to mark current commit as "bad". But hopefully this exit code is not much used by test scripts or other programs. (126 and 127 are used by POSIX compliant shells to mean "found but not executable" and "command not found", respectively.) Signed-off-by: Christian Couder Signed-off-by: Junio C Hamano --- git-bisect.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'git-bisect.sh') diff --git a/git-bisect.sh b/git-bisect.sh index f8d0099059..180c6c280c 100755 --- a/git-bisect.sh +++ b/git-bisect.sh @@ -392,7 +392,10 @@ bisect_run () { fi # Find current state depending on run success or failure. - if [ $res -gt 0 ]; then + # A special exit code of 125 means cannot test. + if [ $res -eq 125 ]; then + state='skip' + elif [ $res -gt 0 ]; then state='bad' else state='good' @@ -404,6 +407,12 @@ bisect_run () { cat "$GIT_DIR/BISECT_RUN" + 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 + if [ $res -ne 0 ]; then echo >&2 "bisect run failed:" echo >&2 "'bisect_state $state' exited with error code $res" -- cgit v1.2.3 From 6ca8b977e4f678050db8fcb0eec2091dd44a2bd0 Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Mon, 29 Oct 2007 05:31:52 +0100 Subject: Bisect: add "skip" to the short usage string. Signed-off-by: Christian Couder Signed-off-by: Junio C Hamano --- git-bisect.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'git-bisect.sh') diff --git a/git-bisect.sh b/git-bisect.sh index 180c6c280c..b74f44df60 100755 --- a/git-bisect.sh +++ b/git-bisect.sh @@ -1,12 +1,14 @@ #!/bin/sh -USAGE='[start|bad|good|next|reset|visualize|replay|log|run]' +USAGE='[start|bad|good|skip|next|reset|visualize|replay|log|run]' LONG_USAGE='git bisect start [ [...]] [--] [...] reset bisect state and start bisection. git bisect bad [] mark a known-bad revision. git bisect good [...] mark ... known-good revisions. +git bisect skip [...] + mark ... untestable revisions. git bisect next find next bisection to test and check it out. git bisect reset [] @@ -17,8 +19,6 @@ git bisect replay replay bisection log. git bisect log show bisect log. -git bisect skip [...] - mark ... untestable revisions. git bisect run ... use ... to automatically bisect.' -- cgit v1.2.3 From 8f321a39257a06db014a3b6ae5dce839821cdb16 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Tue, 6 Nov 2007 01:50:02 -0800 Subject: scripts: Add placeholders for OPTIONS_SPEC --text follows this line-- These commands currently lack OPTIONS_SPEC; allow people to easily list with "git grep 'OPTIONS_SPEC=$'" what they can help improving. Signed-off-by: Junio C Hamano --- git-bisect.sh | 1 + 1 file changed, 1 insertion(+) (limited to 'git-bisect.sh') diff --git a/git-bisect.sh b/git-bisect.sh index b74f44df60..c18bd32bf4 100755 --- a/git-bisect.sh +++ b/git-bisect.sh @@ -22,6 +22,7 @@ git bisect log git bisect run ... use ... to automatically bisect.' +OPTIONS_SPEC= . git-sh-setup require_work_tree -- cgit v1.2.3 From 063036af0832710cfcb1380cc4f9c4597b98cc26 Mon Sep 17 00:00:00 2001 From: Ralf Wildenhues Date: Thu, 8 Nov 2007 22:48:24 +0100 Subject: git-bisect.sh: Fix sed script to work with AIX and BSD sed. \n is not portable in a s/// replacement string, only in the regex part. backslash-newline helps. Signed-off-by: Ralf Wildenhues Signed-off-by: Junio C Hamano --- git-bisect.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'git-bisect.sh') diff --git a/git-bisect.sh b/git-bisect.sh index b74f44df60..1ed44e56ad 100755 --- a/git-bisect.sh +++ b/git-bisect.sh @@ -275,7 +275,8 @@ exit_if_skipped_commits () { 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:" - echo "$_tried" | sed -e 's/[|]/\n/g' + echo "$_tried" | sed -e 's/[|]/\ +/g' echo "We cannot bisect more!" exit 2 fi -- cgit v1.2.3 From 947a604b01a8e81b3d0341d38fbf891289f3c0bb Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Thu, 15 Nov 2007 08:18:07 +0100 Subject: Bisect reset: remove bisect refs that may have been packed. If refs were ever packed in the middle of bisection, the bisect refs were not removed from the "packed-refs" file. This patch fixes this problem by using "git update-ref -d $ref $hash" in "bisect_clean_state". Signed-off-by: Christian Couder Signed-off-by: Junio C Hamano --- git-bisect.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'git-bisect.sh') diff --git a/git-bisect.sh b/git-bisect.sh index 1ed44e56ad..46a7b8d54a 100755 --- a/git-bisect.sh +++ b/git-bisect.sh @@ -351,7 +351,13 @@ bisect_reset() { bisect_clean_state() { rm -fr "$GIT_DIR/refs/bisect" - rm -f "$GIT_DIR/refs/heads/bisect" + + # There may be some refs packed during bisection. + git for-each-ref --format='%(refname) %(objectname)' refs/bisect/\* refs/heads/bisect | + while read ref hash + do + git update-ref -d $ref $hash + done rm -f "$GIT_DIR/BISECT_LOG" rm -f "$GIT_DIR/BISECT_NAMES" rm -f "$GIT_DIR/BISECT_RUN" -- cgit v1.2.3 From e23cb8c0cc0fb9f18e7e7106e2eec692a7b10044 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 15 Nov 2007 00:39:57 -0800 Subject: git-bisect: war on "sed" We do not need to pipe "echo" to "sed" only to strip refs/heads/ from the beginning. We are assuming not-so-ancient shells these days. Also there is no need to avoid assuming \012 is the LF; we do not run on EBCDIC, sorry. Other parts of the script already uses tr to convert separator to LF that way. Signed-off-by: Junio C Hamano --- git-bisect.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'git-bisect.sh') diff --git a/git-bisect.sh b/git-bisect.sh index 46a7b8d54a..3a210335e7 100755 --- a/git-bisect.sh +++ b/git-bisect.sh @@ -71,7 +71,7 @@ bisect_start() { ;; refs/heads/*) [ -s "$GIT_DIR/head-name" ] && die "won't bisect on seeked tree" - echo "$head" | sed 's#^refs/heads/##' >"$GIT_DIR/head-name" + echo "${head#refs/heads/}" >"$GIT_DIR/head-name" ;; *) die "Bad HEAD - strange symbolic ref" @@ -275,8 +275,7 @@ exit_if_skipped_commits () { 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:" - echo "$_tried" | sed -e 's/[|]/\ -/g' + echo "$_tried" | tr '[|]' '[\012]' echo "We cannot bisect more!" exit 2 fi -- cgit v1.2.3 From 3d7cd64cb493e3e30e4398c7b6cd66ee38cb4418 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 15 Nov 2007 00:42:04 -0800 Subject: git-bisect: use update-ref to mark good/bad commits This removes the last instance of making a ref by hand with "echo SHA1 >.git/refs/$refname" from the script and replaces it with update-ref. Signed-off-by: Junio C Hamano --- git-bisect.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git-bisect.sh') diff --git a/git-bisect.sh b/git-bisect.sh index 3a210335e7..4b74a7bb42 100755 --- a/git-bisect.sh +++ b/git-bisect.sh @@ -130,7 +130,7 @@ bisect_write() { good|skip) tag="$state"-"$rev" ;; *) die "Bad bisect_write argument: $state" ;; esac - echo "$rev" >"$GIT_DIR/refs/bisect/$tag" + git update-ref "refs/bisect/$tag" "$rev" echo "# $state: "$(git show-branch $rev) >>"$GIT_DIR/BISECT_LOG" test -z "$nolog" && echo "git-bisect $state $rev" >>"$GIT_DIR/BISECT_LOG" } -- cgit v1.2.3 From 0bee49c6abf18082a01f5d1a2106608456fb7d5a Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 15 Nov 2007 00:47:53 -0800 Subject: git-bisect: modernize branch shuffling hack When switching to a new rev, we first made "new-bisect" branch to point at the chosen commit, attempt to switch to it, and then finally renamed the new-bisect branch to bisect by hand when successful. This is so that we can catch checkout failure (your local modification may interfere with switching to the chosen version) without losing information on which commit the next attempt should be made. Rewrite it using a more modern form but without breaking the safety. Signed-off-by: Junio C Hamano --- git-bisect.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'git-bisect.sh') diff --git a/git-bisect.sh b/git-bisect.sh index 4b74a7bb42..dae8a8e980 100755 --- a/git-bisect.sh +++ b/git-bisect.sh @@ -316,10 +316,9 @@ bisect_next() { exit_if_skipped_commits "$bisect_rev" echo "Bisecting: $bisect_nr revisions left to test after this" - echo "$bisect_rev" >"$GIT_DIR/refs/heads/new-bisect" + git branch -f new-bisect "$bisect_rev" git checkout -q new-bisect || exit - mv "$GIT_DIR/refs/heads/new-bisect" "$GIT_DIR/refs/heads/bisect" && - GIT_DIR="$GIT_DIR" git symbolic-ref HEAD refs/heads/bisect + git branch -M new-bisect bisect git show-branch "$bisect_rev" } -- cgit v1.2.3 From e3f062bfd412adafb7ed6a8f24a3ec89d39211fc Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Sat, 17 Nov 2007 14:35:25 +0100 Subject: Bisect visualize: use "for-each-ref" to list all good refs. In bisect_visualize, "cd $GIT_DIR/refs && echo bisect/good-*" was still used instead of "git for-each-ref". This patch fix it. We now pass "refs/bisect/bad" and "--not refs/bisect/good-" instead of "bisect/bad" and "--not bisect/good-" to gitk, but it seems to work. Signed-off-by: Christian Couder Signed-off-by: Junio C Hamano --- git-bisect.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'git-bisect.sh') diff --git a/git-bisect.sh b/git-bisect.sh index dae8a8e980..2b20037a11 100755 --- a/git-bisect.sh +++ b/git-bisect.sh @@ -324,8 +324,8 @@ bisect_next() { bisect_visualize() { bisect_next_check fail - not=`cd "$GIT_DIR/refs" && echo bisect/good-*` - eval gitk bisect/bad --not $not -- $(cat "$GIT_DIR/BISECT_NAMES") + not=$(git for-each-ref --format='%(refname)' "refs/bisect/good-*") + eval gitk refs/bisect/bad --not $not -- $(cat "$GIT_DIR/BISECT_NAMES") } bisect_reset() { -- cgit v1.2.3 From 6459c7c6786aa9bda0c7a095c9db66c36da0e5f0 Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Sun, 18 Nov 2007 16:34:03 +0100 Subject: Bisect: use "$GIT_DIR/BISECT_NAMES" to check if we are bisecting. Previously we tested if the "$GIT_DIR/refs/bisect" directory existed, to check if we were bisecting. Now with packed refs, it is simpler to check if the file "$GIT_DIR/BISECT_NAMES" exists, as it is already created when starting bisection and removed when reseting bisection. Signed-off-by: Christian Couder Signed-off-by: Junio C Hamano --- git-bisect.sh | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'git-bisect.sh') diff --git a/git-bisect.sh b/git-bisect.sh index 2b20037a11..414f813be7 100755 --- a/git-bisect.sh +++ b/git-bisect.sh @@ -36,7 +36,7 @@ sq() { } bisect_autostart() { - test -d "$GIT_DIR/refs/bisect" || { + test -f "$GIT_DIR/BISECT_NAMES" || { echo >&2 'You need to start by "git bisect start"' if test -t 0 then @@ -82,7 +82,6 @@ bisect_start() { # Get rid of any old bisect state # bisect_clean_state - mkdir "$GIT_DIR/refs/bisect" # # Check for one bad and then some good revisions. @@ -191,7 +190,7 @@ bisect_next_check() { ;; *) THEN='' - test -d "$GIT_DIR/refs/bisect" || { + test -f "$GIT_DIR/BISECT_NAMES" || { echo >&2 'You need to start by "git bisect start".' THEN='then ' } @@ -348,8 +347,6 @@ bisect_reset() { } bisect_clean_state() { - rm -fr "$GIT_DIR/refs/bisect" - # There may be some refs packed during bisection. git for-each-ref --format='%(refname) %(objectname)' refs/bisect/\* refs/heads/bisect | while read ref hash -- cgit v1.2.3 From fce0499fad13815d936c1068b7a064030f543b3d Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Tue, 20 Nov 2007 06:39:53 +0100 Subject: Bisect reset: do nothing when not bisecting. Before this patch, using "git bisect reset" when not bisecting did a "git checkout master" for no good reason. This also happened using "git bisect replay" when not bisecting because "bisect_replay" starts by calling "bisect_reset". Signed-off-by: Christian Couder Signed-off-by: Junio C Hamano --- git-bisect.sh | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'git-bisect.sh') diff --git a/git-bisect.sh b/git-bisect.sh index 414f813be7..6f20a297a5 100755 --- a/git-bisect.sh +++ b/git-bisect.sh @@ -328,6 +328,10 @@ bisect_visualize() { } bisect_reset() { + test -f "$GIT_DIR/BISECT_NAMES" || { + echo "We are not bisecting." + return + } case "$#" in 0) if [ -s "$GIT_DIR/head-name" ]; then branch=`cat "$GIT_DIR/head-name"` -- cgit v1.2.3 From 235997c90fe8648ac199f9a1ae257e06c145c131 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 7 Dec 2007 02:25:34 -0800 Subject: git-bisect visualize: work in non-windowed environments better This teaches "git bisect visualize" to be more useful in non-windowed environments. (1) When no option is given, and $DISPLAY is set, it continues to spawn gitk as before; (2) When no option is given, and $DISPLAY is unset, "git log" is run to show the range of commits between the bad one and the good ones; (3) If only "-flag" options are given, "git log " is run. E.g. "git bisect visualize --stat" (4) Otherwise, all of the given options are taken as the initial part of the command line and the commit range expression is given to that command. E.g. "git bisect visualize tig" will run "tig" history viewer to show between the bad one and the good ones. As "visualize" is a bit too long to type, we also give it a shorter synonym "view". Signed-off-by: Junio C Hamano --- git-bisect.sh | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'git-bisect.sh') diff --git a/git-bisect.sh b/git-bisect.sh index 7a6521ec3c..5385249890 100755 --- a/git-bisect.sh +++ b/git-bisect.sh @@ -324,8 +324,23 @@ bisect_next() { bisect_visualize() { bisect_next_check fail + + if test $# = 0 + then + case "${DISPLAY+set}" in + '') set git log ;; + set) set gitk ;; + esac + else + case "$1" in + git*|tig) ;; + -*) set git log "$@" ;; + *) set git "$@" ;; + esac + fi + not=$(git for-each-ref --format='%(refname)' "refs/bisect/good-*") - eval gitk refs/bisect/bad --not $not -- $(cat "$GIT_DIR/BISECT_NAMES") + eval '"$@"' refs/bisect/bad --not $not -- $(cat "$GIT_DIR/BISECT_NAMES") } bisect_reset() { @@ -449,7 +464,7 @@ case "$#" in next) # Not sure we want "next" at the UI level anymore. bisect_next "$@" ;; - visualize) + visualize|view) bisect_visualize "$@" ;; reset) bisect_reset "$@" ;; -- cgit v1.2.3 From ce32660edc2b83c6fdf550f6869e0b01e255dadb Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Sun, 10 Feb 2008 13:59:50 +0000 Subject: bisect: allow starting with a detached HEAD Instead of insisting on a symbolic ref, bisect now accepts detached HEADs, too. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- git-bisect.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'git-bisect.sh') diff --git a/git-bisect.sh b/git-bisect.sh index 5385249890..393fa35584 100755 --- a/git-bisect.sh +++ b/git-bisect.sh @@ -26,6 +26,9 @@ OPTIONS_SPEC= . git-sh-setup require_work_tree +_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" + sq() { @@PERL@@ -e ' for (@ARGV) { @@ -60,7 +63,8 @@ bisect_start() { # top-of-line master first! # head=$(GIT_DIR="$GIT_DIR" git symbolic-ref HEAD) || - die "Bad HEAD - I need a symbolic ref" + head=$(GIT_DIR="$GIT_DIR" git rev-parse --verify HEAD) || + die "Bad HEAD - I need a HEAD" case "$head" in refs/heads/bisect) if [ -s "$GIT_DIR/head-name" ]; then @@ -70,7 +74,7 @@ bisect_start() { fi git checkout $branch || exit ;; - refs/heads/*) + refs/heads/*|$_x40) [ -s "$GIT_DIR/head-name" ] && die "won't bisect on seeked tree" echo "${head#refs/heads/}" >"$GIT_DIR/head-name" ;; -- cgit v1.2.3 From f454cdc48f31e64ceae2e8d4f4838349de2f5dee Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 12 Feb 2008 19:50:57 +0000 Subject: bisect: use verbatim commit subject in the bisect log Due to a typo, the commit subject was shell expanded in the bisect log. That is, if you had some shell pattern in the commit subject, bisect would happily put all matching file names into the log. Signed-off-by: Johannes Schindelin Tested-by: Frans Pop Signed-off-by: Junio C Hamano --- git-bisect.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'git-bisect.sh') diff --git a/git-bisect.sh b/git-bisect.sh index 393fa35584..6594a62919 100755 --- a/git-bisect.sh +++ b/git-bisect.sh @@ -135,7 +135,7 @@ bisect_write() { *) die "Bad bisect_write argument: $state" ;; esac git update-ref "refs/bisect/$tag" "$rev" - echo "# $state: "$(git show-branch $rev) >>"$GIT_DIR/BISECT_LOG" + echo "# $state: $(git show-branch $rev)" >>"$GIT_DIR/BISECT_LOG" test -z "$nolog" && echo "git-bisect $state $rev" >>"$GIT_DIR/BISECT_LOG" } -- cgit v1.2.3 From 508e84a790bef46881459891748727c490d9a673 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Thu, 14 Feb 2008 12:29:58 +0000 Subject: bisect view: check for MinGW32 and MacOSX in addition to X11 When deciding if gitk or git-log should be used to visualize the current state, the environment variable DISPLAY was checked. Now, we check MSYSTEM (for MinGW32/MSys) and SECURITYSESSIONID (for MacOSX) in addition. Note that there is currently no way to ssh into MinGW32, and that SECURITYSESSIONID is not set automatically on MacOSX when ssh'ing into it. So this patch should be safe. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- git-bisect.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'git-bisect.sh') diff --git a/git-bisect.sh b/git-bisect.sh index 6594a62919..74715edf0b 100755 --- a/git-bisect.sh +++ b/git-bisect.sh @@ -331,9 +331,9 @@ bisect_visualize() { if test $# = 0 then - case "${DISPLAY+set}" in + case "${DISPLAY+set}${MSYSTEM+set}${SECURITYSESSIONID+set}" in '') set git log ;; - set) set gitk ;; + set*) set gitk ;; esac else case "$1" in -- cgit v1.2.3