All of lore.kernel.org
 help / color / mirror / Atom feed
* [BUG] incorrect line numbers reported in git am
@ 2019-10-02 18:45 Denton Liu
  2019-10-02 19:44 ` Junio C Hamano
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Denton Liu @ 2019-10-02 18:45 UTC (permalink / raw)
  To: git; +Cc: Paul Tan, Nguyễn Thái Ngọc Duy, Jeff King

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2019-10-05 22:51 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.