Re: [PATCH v2 1/3] parse_insn_line(): improve error message when parsing failed
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Jan 23, 2020, 12:26 UTC
- Message-ID
- <nycvar.QRO.7.76.6.2001231326310.46@tvgsbejvaqbjf.bet>
- In-Reply-To
- <xmqqlfq08nzz.fsf@gitster-ct.c.googlers.com>
Hi Junio,
On Tue, 21 Jan 2020, Junio C Hamano wrote:
Show 32 quoted lines
> "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
> writes:
>
> > From: Johannes Schindelin <johannes.schindelin@gmx.de>
> >
> > In the case that a `get_oid()` call failed, we showed some rather bogus
> > part of the line instead of the precise string we sent to said function.
> > That makes it rather hard for users to understand what is going wrong,
> > so let's fix that.
> >
> > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> > ...
> > @@ -2125,11 +2127,10 @@ static int parse_insn_line(struct repository *r, struct todo_item *item,
> > item->arg_len = (int)(eol - bol);
> >
> > if (status < 0)
> > - return error(_("could not parse '%.*s'"),
> > - (int)(end_of_object_name - bol), bol);
> > + return status;
> >
> > item->commit = lookup_commit_reference(r, &commit_oid);
> > - return !item->commit;
> > + return item->commit ? 0 : -1;
>
> This changes the polarity of the error exit from positive 1 to
> negative 1. The only caller of this function takes anything
> non-zero as a failure so this would not cause behaviour change, but
> returning negative is more in line with the practice so it is an
> improvement.
>
> It is unrelated to the theme of this patch, and the proposed log
> message does not even mention it, though.You're right. I amended the commit message. Will send out a v3 soon.
Thanks, Dscho