Re: [BUG] incorrect line numbers reported in git am
To
Denton Liu
Cc
git@vger.kernel.org
Paul Tan
Nguyễn Thái Ngọc Duy
Jeff King
From
Junio C Hamano
See Also
Prev Ref 1 Ref 2
Date
2019-10-03 00:52:55 UTC
Denton Liu <liu.denton@gmail.com> writes:

> On Thu, Oct 03, 2019 at 05:03:14AM +0900, Junio C Hamano wrote:
>> Denton Liu <liu.denton@gmail.com> writes:
>> 
>> > which is in the middle of the log message. I expect the line to be
>> > reported as something in the range of 198-203,...
>> 
>> That comes from not knowing who is complaining and what it is
>> reading.  In this case, "git apply" issues a warning because it is
>> fed .git/rebase-apply/patch file, which is the output of mailinfo
>> that parses header & log message out, leaves the message in a
>> separate 'msg' file in the same directory and stores the rest in
>> that 'patch' file.  And it is line 87 that has problems.
>
> In this case, I would still regard this as a bug since users would
> expect the line 87 to refer to their input file. I think most users
> don't even realise that a .git/rebase-apply/patch file exists. (I
> certainly didn't.)

In any case, if the error message required me to look anywhere
outside the patch file, it would make it impossible for me to work.

100% of the time, I just pipe the entire message from MUA to "git
am", and I wouldn't know which line it is complaining if it counted
the long run of mail headers like Received:, etc., because I do not
have such an entire message anywhere in a single file (only my MUA
has it, so I'd need to pipe it to "cat >tempfile" again after seeing
a failure).

> In fact, running `git am --show-current-patch` shows the whole mail, not
> only the 'patch' file so users would have no reason to expect the line
> numbers to refer to the 'patch' file.

Yeah, show-current-patch was a misguided attempt to hide useful
information from the users.