{"thread":{"id":"18718","subject":"[PATCH] bisect: improve error message when branch checkout fails","startedAt":"2009-04-04T20:02:26Z","lastAt":"2009-04-05T09:46:51Z","messageCount":2,"participants":["Christian Couder","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"110343","messageId":"20090404220226.58a3ac99.chriscool@tuxfamily.org","threadId":"18718","inReplyTo":null,"subject":"[PATCH] bisect: improve error message when branch checkout fails","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2009-04-04T20:02:26Z","receivedAt":"2009-04-04T20:02:26Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"In \"git-bisect.sh\" the \"git checkout\" command is only used to\nchange the current branch, but it is used like this:\n\ngit checkout \"$branch\"\n\nwhich will output the following misleading error message when\nit fails:\n\nerror: pathspec 'foo' did not match any file(s) known to git.\n\nThis patch change the way we use \"git checkout\" like this:\n\ngit checkout \"$branch\" --\n\nso that we will get the following error message:\n\nfatal: invalid reference: foo\n\nwhich is better.\n\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n git-bisect.sh |    6 +++---\n 1 files changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/git-bisect.sh b/git-bisect.sh\nindex e313bde..df0ae63 100755\n--- a/git-bisect.sh\n+++ b/git-bisect.sh\n@@ -77,7 +77,7 @@ bisect_start() {\n \tthen\n \t\t# Reset to the rev from where we started.\n \t\tstart_head=$(cat \"$GIT_DIR/BISECT_START\")\n-\t\tgit checkout \"$start_head\" || exit\n+\t\tgit checkout \"$start_head\" -- || exit\n \telse\n \t\t# Get rev from where we start.\n \t\tcase \"$head\" in\n@@ -370,7 +370,7 @@ bisect_checkout() {\n \t_msg=\"$2\"\n \techo \"Bisecting: $_msg\"\n \tmark_expected_rev \"$_rev\"\n-\tgit checkout -q \"$_rev\" || exit\n+\tgit checkout -q \"$_rev\" -- || exit\n \tgit show-branch \"$_rev\"\n }\n \n@@ -549,7 +549,7 @@ bisect_reset() {\n \t*)\n \t    usage ;;\n \tesac\n-\tgit checkout \"$branch\" && bisect_clean_state\n+\tgit checkout \"$branch\" -- && bisect_clean_state\n }\n \n bisect_clean_state() {\n-- \n1.6.2.2.404.ge96f3.dirty\n"},{"id":"110395","messageId":"7vskknv3ec.fsf@gitster.siamese.dyndns.org","threadId":"18718","inReplyTo":"20090404220226.58a3ac99.chriscool@tuxfamily.org","subject":"Re: [PATCH] bisect: improve error message when branch checkout fails","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-04-05T09:46:51Z","receivedAt":"2009-04-05T09:46:51Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Christian Couder <chriscool@tuxfamily.org> writes:\n\n> In \"git-bisect.sh\" the \"git checkout\" command is only used to\n> change the current branch, but it is used like this:\n>\n> git checkout \"$branch\"\n>\n> which will output the following misleading error message when\n> it fails:\n>\n> error: pathspec 'foo' did not match any file(s) known to git.\n>\n> This patch change the way we use \"git checkout\" like this:\n>\n> git checkout \"$branch\" --\n>\n> so that we will get the following error message:\n>\n> fatal: invalid reference: foo\n>\n> which is better.\n\nThanks; will apply.\n\nBut I think \"git checkout\" should either say \"unknown branch\" (assuming\nthat most people switch branches, not detach HEAD), or \"no such commit\"\n(which could be a bit confusing for people who have not even heard of\ndetached HEAD, but may be more technically correct).\n\n\"Invalid reference\" does not help anybody and is not technically correct,\neither.  A git newbie would say \"Huh?  what is a ref?\" and a git savvy\nwould say \"I admit I made a typo, but you, the git checkout command, are\nsupposed to take an arbitrary commit object, not necessarily a ref\".\n"}]}