Skip to content

Commit 412ff73

Browse files
szedergitster
authored andcommitted
bisect: improve error message of 'bisect log' while not bisecting
'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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c752e7f commit 412ff73

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

git-bisect.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,10 @@ bisect_run () {
412412
done
413413
}
414414

415+
bisect_log () {
416+
test -s "$GIT_DIR/BISECT_LOG" || die "We are not bisecting."
417+
cat "$GIT_DIR/BISECT_LOG"
418+
}
415419

416420
case "$#" in
417421
0)
@@ -438,7 +442,7 @@ case "$#" in
438442
replay)
439443
bisect_replay "$@" ;;
440444
log)
441-
cat "$GIT_DIR/BISECT_LOG" ;;
445+
bisect_log ;;
442446
run)
443447
bisect_run "$@" ;;
444448
*)

0 commit comments

Comments
 (0)