From 412ff738addd3f329d641073fd1aa32629d5bfbf Mon Sep 17 00:00:00 2001 From: =?utf8?q?SZEDER=20G=C3=A1bor?= Date: Sun, 10 Oct 2010 23:48:56 +0200 Subject: [PATCH] bisect: improve error message of 'bisect log' while not bisecting MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit '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 Signed-off-by: Junio C Hamano --- git-bisect.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/git-bisect.sh b/git-bisect.sh index 6e2acb8ef2..3a4bf8150d 100755 --- a/git-bisect.sh +++ b/git-bisect.sh @@ -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) @@ -438,7 +442,7 @@ case "$#" in replay) bisect_replay "$@" ;; log) - cat "$GIT_DIR/BISECT_LOG" ;; + bisect_log ;; run) bisect_run "$@" ;; *) -- 2.11.4.GIT