From 412ff738addd3f329d641073fd1aa32629d5bfbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?SZEDER=20G=C3=A1bor?= Date: Sun, 10 Oct 2010 23:48:56 +0200 Subject: [PATCH 1/3] bisect: improve error message of 'bisect log' while not bisecting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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 "$@" ;; *) From 3bb8cf88247db589b60e79c0520b081793cfd68e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?SZEDER=20G=C3=A1bor?= Date: Sun, 10 Oct 2010 23:48:57 +0200 Subject: [PATCH 2/3] bisect: improve error msg of 'bisect reset' when original HEAD is deleted MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 'git bisect reset' (without the optional argument) returns to the original HEAD from where the bisection was started. However, when, for whatever reason, the user deleted the original HEAD before invoking 'git bisect reset', then all he gets is an error message from 'git checkout': fatal: invalid reference: somebranch Let's try to be more helpful with an error message better describing what went wrong and a suggestion about how to resolve the situation: Could not check out original HEAD 'somebranch'. Try 'git bisect reset '. Signed-off-by: SZEDER Gábor Signed-off-by: Junio C Hamano --- git-bisect.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/git-bisect.sh b/git-bisect.sh index 3a4bf8150d..68fcff6dbf 100755 --- a/git-bisect.sh +++ b/git-bisect.sh @@ -316,7 +316,12 @@ bisect_reset() { *) usage ;; esac - git checkout "$branch" -- && bisect_clean_state + if git checkout "$branch" -- ; then + bisect_clean_state + else + die "Could not check out original HEAD '$branch'." \ + "Try 'git bisect reset '." + fi } bisect_clean_state() { From 2c7c3877def8629278f5367a461ef269b0cfaa99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?SZEDER=20G=C3=A1bor?= Date: Sun, 10 Oct 2010 23:48:58 +0200 Subject: [PATCH 3/3] bisect: check for mandatory argument of 'bisect replay' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 'git bisect replay' has a mandatory logfile argument, but the current implementation doesn't check whether the user has specified one. When the user omits the logfile argument, this leads to the following unhelpful error message: cannot read for replaying So, check for the mandatory argument first, and provide a more meaningful error message when it is omitted. Signed-off-by: SZEDER Gábor Signed-off-by: Junio C Hamano --- git-bisect.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/git-bisect.sh b/git-bisect.sh index 68fcff6dbf..c21e33c8d1 100755 --- a/git-bisect.sh +++ b/git-bisect.sh @@ -343,6 +343,7 @@ bisect_clean_state() { } bisect_replay () { + test "$#" -eq 1 || die "No logfile given" test -r "$1" || die "cannot read $1 for replaying" bisect_reset while read git bisect command rev