{"thread":{"id":"25415","subject":"[PATCH 2/3] bisect: improve error msg of 'bisect reset' when original HEAD is deleted","startedAt":"2010-10-10T21:48:56Z","lastAt":"2010-10-14T07:55:53Z","messageCount":8,"participants":["SZEDER Gábor","Ævar Arnfjörð Bjarmason","Christian Couder","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"153191","messageId":"1286747338-8521-1-git-send-email-szeder@ira.uka.de","threadId":"25415","inReplyTo":null,"subject":"[PATCH 1/3] bisect: improve error message of 'bisect log' while not bisecting","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2010-10-10T21:48:56Z","receivedAt":"2010-10-10T21:48:56Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"'git bisect log' is implemented by a direct invocation of 'cat\n\"$GIT_DIR/BISECT_LOG\"', without any sanity checks.  Consequently,\nrunning 'git bisect log' while not bisecting leads to an error,\nbecause the bisect logfile doesn't exists.  The accompanying error\nmessage\n\n  cat: /path/to/repo/.git/BISECT_LOG: No such file or directory\n\nis neither very helpful nor very friendly.\n\nInstead of blindly trying to cat the log file, first check whether\nthere is a bisection going on (i.e. the bisect logfile exists), and\ndie with a more appropriate error message when not.\n\nSigned-off-by: SZEDER Gábor <szeder@ira.uka.de>\n---\n git-bisect.sh |    6 +++++-\n 1 files changed, 5 insertions(+), 1 deletions(-)\n\ndiff --git a/git-bisect.sh b/git-bisect.sh\nindex 6e2acb8..3a4bf81 100755\n--- a/git-bisect.sh\n+++ b/git-bisect.sh\n@@ -412,6 +412,10 @@ bisect_run () {\n     done\n }\n \n+bisect_log () {\n+\ttest -s \"$GIT_DIR/BISECT_LOG\" || die \"We are not bisecting.\"\n+\tcat \"$GIT_DIR/BISECT_LOG\"\n+}\n \n case \"$#\" in\n 0)\n@@ -438,7 +442,7 @@ case \"$#\" in\n     replay)\n \tbisect_replay \"$@\" ;;\n     log)\n-\tcat \"$GIT_DIR/BISECT_LOG\" ;;\n+\tbisect_log ;;\n     run)\n         bisect_run \"$@\" ;;\n     *)\n-- \n1.7.3.1.148.g2fffa\n"},{"id":"153189","messageId":"1286747338-8521-2-git-send-email-szeder@ira.uka.de","threadId":"25415","inReplyTo":"1286747338-8521-1-git-send-email-szeder@ira.uka.de","subject":"[PATCH 2/3] bisect: improve error msg of 'bisect reset' when original HEAD is deleted","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2010-10-10T21:48:57Z","receivedAt":"2010-10-10T21:48:57Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"'git bisect reset' (without the optional <commit> argument) returns to\nthe original HEAD from where the bisection was started.  However,\nwhen, for whatever reason, the user deleted the original HEAD before\ninvoking 'git bisect reset', then all he gets is an error message from\n'git checkout':\n\n  fatal: invalid reference: somebranch\n\nLet's try to be more helpful with an error message better describing\nwhat went wrong and a suggestion about how to resolve the situation:\n\n  Could not check out original HEAD 'somebranch'. Try 'git bisect reset <commit>'.\n\nSigned-off-by: SZEDER Gábor <szeder@ira.uka.de>\n---\n git-bisect.sh |    7 ++++++-\n 1 files changed, 6 insertions(+), 1 deletions(-)\n\ndiff --git a/git-bisect.sh b/git-bisect.sh\nindex 3a4bf81..68fcff6 100755\n--- a/git-bisect.sh\n+++ b/git-bisect.sh\n@@ -316,7 +316,12 @@ bisect_reset() {\n \t*)\n \t    usage ;;\n \tesac\n-\tgit checkout \"$branch\" -- && bisect_clean_state\n+\tif git checkout \"$branch\" -- ; then\n+\t\tbisect_clean_state\n+\telse\n+\t\tdie \"Could not check out original HEAD '$branch'.\" \\\n+\t\t\t\t\"Try 'git bisect reset <commit>'.\"\n+\tfi\n }\n \n bisect_clean_state() {\n-- \n1.7.3.1.148.g2fffa\n"},{"id":"153190","messageId":"1286747338-8521-3-git-send-email-szeder@ira.uka.de","threadId":"25415","inReplyTo":"1286747338-8521-1-git-send-email-szeder@ira.uka.de","subject":"[PATCH 3/3] bisect: check for mandatory argument of 'bisect replay'","fromName":"SZEDER Gábor","fromEmail":"szeder@ira.uka.de","sentAt":"2010-10-10T21:48:58Z","receivedAt":"2010-10-10T21:48:58Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"'git bisect replay' has a mandatory logfile argument, but the current\nimplementation doesn't check whether the user has specified one.  When\nthe user omits the logfile argument, this leads to the following\nunhelpful error message:\n\n  cannot read  for replaying\n\nSo, check for the mandatory argument first, and provide a more\nmeaningful error message when it is omitted.\n\nSigned-off-by: SZEDER Gábor <szeder@ira.uka.de>\n---\n git-bisect.sh |    1 +\n 1 files changed, 1 insertions(+), 0 deletions(-)\n\ndiff --git a/git-bisect.sh b/git-bisect.sh\nindex 68fcff6..c21e33c 100755\n--- a/git-bisect.sh\n+++ b/git-bisect.sh\n@@ -343,6 +343,7 @@ bisect_clean_state() {\n }\n \n bisect_replay () {\n+\ttest \"$#\" -eq 1 || die \"No logfile given\"\n \ttest -r \"$1\" || die \"cannot read $1 for replaying\"\n \tbisect_reset\n \twhile read git bisect command rev\n-- \n1.7.3.1.148.g2fffa\n"},{"id":"153221","messageId":"AANLkTi=KZyhJrYw+L2U6gsu=jNcBe8eRJTG4jSuPTYsT@mail.gmail.com","threadId":"25415","inReplyTo":"1286747338-8521-1-git-send-email-szeder@ira.uka.de","subject":"Re: [PATCH 1/3] bisect: improve error message of 'bisect log' while not bisecting","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2010-10-11T06:44:42Z","receivedAt":"2010-10-11T06:44:42Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"2010/10/10 SZEDER Gábor <szeder@ira.uka.de>:\n> 'git bisect log' is implemented by a direct invocation of 'cat\n> \"$GIT_DIR/BISECT_LOG\"', without any sanity checks.  Consequently,\n> running 'git bisect log' while not bisecting leads to an error,\n> because the bisect logfile doesn't exists.  The accompanying error\n> message\n\nNice, in case you want to fix this for git-rebase too:\n\nApplying: gettextize: git-add \"no files added\" message\nApplying: gettextize: git-add \"Use -f if you really want\" message\nApplying: gettextize: git-add \"pathspec [...] did not match\" message\nApplying: gettextize: git-add \"remove '%s'\" message\n^C\nv t ((5cab536...)|REBASE) $ git rebase --abort\ncat: /home/avar/g/git/.git/rebase-apply/head-name: No such file or directory\ncat: /home/avar/g/git/.git/rebase-apply/orig-head: No such file or directory\nHEAD is now at 5cab536 gettextize: git-add \"remove '%s'\" message\nv t ((5cab536...)) $\nv t ((5cab536...)) $ git rebase --abort\nNo rebase in progress?\nv t ((5cab536...)) $\n"},{"id":"153286","messageId":"201010120435.11903.chriscool@tuxfamily.org","threadId":"25415","inReplyTo":"1286747338-8521-3-git-send-email-szeder@ira.uka.de","subject":"Re: [PATCH 3/3] bisect: check for mandatory argument of 'bisect replay'","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2010-10-12T02:35:11Z","receivedAt":"2010-10-12T02:35:11Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"On Sunday 10 October 2010 23:48:58 SZEDER Gábor wrote:\n> 'git bisect replay' has a mandatory logfile argument, but the current\n> implementation doesn't check whether the user has specified one.  When\n> the user omits the logfile argument, this leads to the following\n> unhelpful error message:\n> \n>   cannot read  for replaying\n> \n> So, check for the mandatory argument first, and provide a more\n> meaningful error message when it is omitted.\n> \n> Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>\n> ---\n>  git-bisect.sh |    1 +\n>  1 files changed, 1 insertions(+), 0 deletions(-)\n> \n> diff --git a/git-bisect.sh b/git-bisect.sh\n> index 68fcff6..c21e33c 100755\n> --- a/git-bisect.sh\n> +++ b/git-bisect.sh\n> @@ -343,6 +343,7 @@ bisect_clean_state() {\n>  }\n> \n>  bisect_replay () {\n> +\ttest \"$#\" -eq 1 || die \"No logfile given\"\n>  \ttest -r \"$1\" || die \"cannot read $1 for replaying\"\n>  \tbisect_reset\n>  \twhile read git bisect command rev\n\nWhile at it perhaps you could do something like:\n\nbisect_replay () {\n+\ttest \"$#\" -lt 1 || die \"No logfile given\"\n+\ttest \"$#\" -gt 1 || die \"Too many argument. Please give only one logfile.\"\n \ttest -r \"$1\" || die \"cannot read $1 for replaying\"\n \tbisect_reset\n \twhile read git bisect command rev\n\nThanks,\nChristian.\n"},{"id":"153287","messageId":"201010120456.35411.chriscool@tuxfamily.org","threadId":"25415","inReplyTo":"201010120435.11903.chriscool@tuxfamily.org","subject":"Re: [PATCH 3/3] bisect: check for mandatory argument of 'bisect replay'","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2010-10-12T02:56:35Z","receivedAt":"2010-10-12T02:56:35Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"On Tuesday 12 October 2010 04:35:11 Christian Couder wrote:\n> On Sunday 10 October 2010 23:48:58 SZEDER Gábor wrote:\n> > 'git bisect replay' has a mandatory logfile argument, but the current\n> > implementation doesn't check whether the user has specified one.  When\n> > the user omits the logfile argument, this leads to the following\n> > \n> > unhelpful error message:\n> >   cannot read  for replaying\n> > \n> > So, check for the mandatory argument first, and provide a more\n> > meaningful error message when it is omitted.\n> > \n> > Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>\n> > ---\n> > \n> >  git-bisect.sh |    1 +\n> >  1 files changed, 1 insertions(+), 0 deletions(-)\n> > \n> > diff --git a/git-bisect.sh b/git-bisect.sh\n> > index 68fcff6..c21e33c 100755\n> > --- a/git-bisect.sh\n> > +++ b/git-bisect.sh\n> > @@ -343,6 +343,7 @@ bisect_clean_state() {\n> > \n> >  }\n> >  \n> >  bisect_replay () {\n> > \n> > +\ttest \"$#\" -eq 1 || die \"No logfile given\"\n> > \n> >  \ttest -r \"$1\" || die \"cannot read $1 for replaying\"\n> >  \tbisect_reset\n> >  \twhile read git bisect command rev\n> \n> While at it perhaps you could do something like:\n> \n> bisect_replay () {\n> +\ttest \"$#\" -lt 1 || die \"No logfile given\"\n> +\ttest \"$#\" -gt 1 || die \"Too many argument. Please give only one logfile.\"\n>  \ttest -r \"$1\" || die \"cannot read $1 for replaying\"\n>  \tbisect_reset\n>  \twhile read git bisect command rev\n\nI mean:\n\nbisect_replay () {\n+\ttest \"$#\" -lt 1 && die \"No logfile given\"\n+\ttest \"$#\" -gt 1 && die \"Too many argument. Please give only one logfile.\"\n \ttest -r \"$1\" || die \"cannot read $1 for replaying\"\n \tbisect_reset\n \twhile read git bisect command rev\n\nSorry!\n\nBest regards,\nChristian.\n"},{"id":"153423","messageId":"7viq16m0tk.fsf@alter.siamese.dyndns.org","threadId":"25415","inReplyTo":"201010120456.35411.chriscool@tuxfamily.org","subject":"Re: [PATCH 3/3] bisect: check for mandatory argument of 'bisect replay'","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-10-13T17:58:47Z","receivedAt":"2010-10-13T17:58:47Z","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>> >  bisect_replay () {\n>> > \n>> > +\ttest \"$#\" -eq 1 || die \"No logfile given\"\n>> > \n>> >  \ttest -r \"$1\" || die \"cannot read $1 for replaying\"\n>> >  \tbisect_reset\n>> >  \twhile read git bisect command rev\n>> \n>> While at it perhaps you could do something like:\n>> \n>> bisect_replay () {\n>> +\ttest \"$#\" -lt 1 || die \"No logfile given\"\n>> +\ttest \"$#\" -gt 1 || die \"Too many argument. Please give only one logfile.\"\n>>  \ttest -r \"$1\" || die \"cannot read $1 for replaying\"\n>>  \tbisect_reset\n>>  \twhile read git bisect command rev\n>\n> I mean:\n>\n> bisect_replay () {\n> +\ttest \"$#\" -lt 1 && die \"No logfile given\"\n> +\ttest \"$#\" -gt 1 && die \"Too many argument. Please give only one logfile.\"\n>  \ttest -r \"$1\" || die \"cannot read $1 for replaying\"\n>  \tbisect_reset\n>  \twhile read git bisect command rev\n\nThat suggests that the original patch is buggy as well, in that it says\n\"No logfile given\" when it gets two.\n\nHow about checking with 1 and saying \"Give me only one logfile\" and be\ndone with it?\n"},{"id":"153493","messageId":"AANLkTi=HCHy0q4atzVYUGO0hQ3FBigZcFDsFLv9iZ=h-@mail.gmail.com","threadId":"25415","inReplyTo":"7viq16m0tk.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 3/3] bisect: check for mandatory argument of 'bisect replay'","fromName":"Christian Couder","fromEmail":"christian.couder@gmail.com","sentAt":"2010-10-14T07:55:53Z","receivedAt":"2010-10-14T07:55:53Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"On Wed, Oct 13, 2010 at 7:58 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Christian Couder <chriscool@tuxfamily.org> writes:\n>\n>>> >  bisect_replay () {\n>>> >\n>>> > +  test \"$#\" -eq 1 || die \"No logfile given\"\n>>> >\n>>> >    test -r \"$1\" || die \"cannot read $1 for replaying\"\n>>> >    bisect_reset\n>>> >    while read git bisect command rev\n>>>\n>>> While at it perhaps you could do something like:\n>>>\n>>> bisect_replay () {\n>>> +    test \"$#\" -lt 1 || die \"No logfile given\"\n>>> +    test \"$#\" -gt 1 || die \"Too many argument. Please give only one logfile.\"\n>>>      test -r \"$1\" || die \"cannot read $1 for replaying\"\n>>>      bisect_reset\n>>>      while read git bisect command rev\n>>\n>> I mean:\n>>\n>> bisect_replay () {\n>> +     test \"$#\" -lt 1 && die \"No logfile given\"\n>> +     test \"$#\" -gt 1 && die \"Too many argument. Please give only one logfile.\"\n>>       test -r \"$1\" || die \"cannot read $1 for replaying\"\n>>       bisect_reset\n>>       while read git bisect command rev\n>\n> That suggests that the original patch is buggy as well, in that it says\n> \"No logfile given\" when it gets two.\n>\n> How about checking with 1 and saying \"Give me only one logfile\" and be\n> done with it?\n\nYeah or: \"Give me exactly one logfile as argument\"\n\nBest regards,\nChristian.\n"}]}