Skip to content

Commit

Permalink
bisect: improve error message of 'bisect log' while not bisecting
Browse files Browse the repository at this point in the history
'git bisect log' is implemented by a direct invocation of 'cat
"$GIT_DIR/BISECT_LOG"', without any sanity checks.  Consequently,
running 'git bisect log' while not bisecting leads to an error,
because the bisect logfile doesn't exists.  The accompanying error
message

  cat: /path/to/repo/.git/BISECT_LOG: No such file or directory

is neither very helpful nor very friendly.

Instead of blindly trying to cat the log file, first check whether
there is a bisection going on (i.e. the bisect logfile exists), and
die with a more appropriate error message when not.

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
SZEDER Gábor authored and Junio C Hamano committed Oct 13, 2010
1 parent c752e7f commit 412ff73
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion git-bisect.sh
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,10 @@ bisect_run () {
done
}

bisect_log () {
test -s "$GIT_DIR/BISECT_LOG" || die "We are not bisecting."
cat "$GIT_DIR/BISECT_LOG"
}

case "$#" in
0)
Expand All @@ -438,7 +442,7 @@ case "$#" in
replay)
bisect_replay "$@" ;;
log)
cat "$GIT_DIR/BISECT_LOG" ;;
bisect_log ;;
run)
bisect_run "$@" ;;
*)
Expand Down

0 comments on commit 412ff73

Please sign in to comment.