From: Denton Liu <liu.denton@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, "Paul Tan" <pyokagan@gmail.com>,
"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>,
"Jeff King" <peff@peff.net>
Subject: Re: [BUG] incorrect line numbers reported in git am
Date: Wed, 2 Oct 2019 13:08:36 -0700 [thread overview]
Message-ID: <20191002200836.GA24697@generichostname> (raw)
In-Reply-To: <xmqqd0ffdj9k.fsf@gitster-ct.c.googlers.com>
On Thu, Oct 03, 2019 at 04:44:55AM +0900, Junio C Hamano wrote:
> Denton Liu <liu.denton@gmail.com> writes:
>
> > Applying: dir: special case check for the possibility that pathspec is NULL
> > error: corrupt patch at line 87
>
> This refers to line 87 of the input file, not a line that begins
> with "@@ -87,count...", doesn't it?
Correct, it refers to line 87 of the input file. Since the whole mail is
202 lines long and the faulty hunk comes at the end of the whole mail,
I'd expect the faulty line number to say something like line 198 or
something that's near the end of the mail. Line 87 is somewhere in the
middle of the log message in the mail.
I think the problem comes from line number being expressed as an offset
from the "---" (begin diff) line as opposed to an offset from the actual
beginning of the mail.
> If the sender hand edits a
> patch without correcting the number of lines recorded in the hunk
> header, the parser may not see the next hunk that begins with "@@"
> or run out of the input before it reads the required number of lines
> given the last hunk header.
Correct, but I think that's orthogonal to the main issue. It makes sense
why the error is being reported but what doesn't make sense is the fact
that the line numbers reported are so far off from what a user would
expect.
>
> We might be able to notice when the input file is shorter than the
> last hunk wants it to be, in which case we should be able to say
> 'premature end of input at line 87' or something like that.
Yep, I noticed this bug while I was writing a patch to do exactly that.
>
>
next prev parent reply other threads:[~2019-10-02 20:08 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-02 18:45 [BUG] incorrect line numbers reported in git am Denton Liu
2019-10-02 19:44 ` Junio C Hamano
2019-10-02 20:08 ` Denton Liu [this message]
2019-10-02 20:03 ` Junio C Hamano
2019-10-02 20:16 ` Denton Liu
2019-10-03 0:52 ` Junio C Hamano
2019-10-03 6:17 ` Duy Nguyen
2019-10-03 22:56 ` Junio C Hamano
2019-10-04 21:59 ` [PATCH] apply: tell user location of corrupted patch file Denton Liu
2019-10-05 8:33 ` Junio C Hamano
2019-10-05 22:44 ` Junio C Hamano
2019-10-05 22:51 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191002200836.GA24697@generichostname \
--to=liu.denton@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=pclouds@gmail.com \
--cc=peff@peff.net \
--cc=pyokagan@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).