From: Denton Liu <liu.denton@gmail.com>
To: git@vger.kernel.org
Cc: "Paul Tan" <pyokagan@gmail.com>,
"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>,
"Jeff King" <peff@peff.net>
Subject: [BUG] incorrect line numbers reported in git am
Date: Wed, 2 Oct 2019 11:45:46 -0700 [thread overview]
Message-ID: <20191002184546.GA22174@generichostname> (raw)
Hello all,
I found a bug where the line numbers in git am are being reported
incorrectly in the case where a patch fails to apply cleanly.
The test case for this is pretty simple:
$ wget https://public-inbox.org/git/20191001185524.18772-1-newren@gmail.com/raw
$ git am raw
And the output for this is:
Applying: dir: special case check for the possibility that pathspec is NULL
error: corrupt patch at line 87
Patch failed at 0001 dir: special case check for the possibility that pathspec is NULL
hint: Use 'git am --show-current-patch' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
In this case, the path is indeed corrupt. The final hunk header gives 25
lines after instead of 24 lines. As a result, it is erroring out
correctly.
However, the line offsets are off. Line 87, as it reports, is the
following:
to avoid a segfault.
which is in the middle of the log message. I expect the line to be
reported as something in the range of 198-203, where the end of the hunk
actually is.
Indeed, if you take an 87 line offset from the cutoff "---", we can see
that it gives us line 201, which appears at the end of the corrupt hunk.
So it appears that the bug is a result of the the apply process not
taking into account the number of lines from the mail parsing step.
Thanks,
Denton
next reply other threads:[~2019-10-02 18:45 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-02 18:45 Denton Liu [this message]
2019-10-02 19:44 ` [BUG] incorrect line numbers reported in git am Junio C Hamano
2019-10-02 20:08 ` Denton Liu
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191002184546.GA22174@generichostname \
--to=liu.denton@gmail.com \
--cc=git@vger.kernel.org \
--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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).