Skip to content

Fix incorrectly reported line numbers when running git am #374

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Denton-L opened this issue Oct 2, 2019 · 2 comments
Open

Fix incorrectly reported line numbers when running git am #374

Denton-L opened this issue Oct 2, 2019 · 2 comments

Comments

@Denton-L
Copy link
Member

Denton-L commented Oct 2, 2019

See this report for more details.

@dscho
Copy link
Member

dscho commented Oct 2, 2019

See this report for more details.

Pasted here for convenience:

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/[email protected]/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.

@Denton-L
Copy link
Member Author

Denton-L commented Oct 8, 2019

Initial patch here: https://public-inbox.org/git/ec38908d05f0d40190173158ef3f0753fa9f1184.1570226253.git.liu.denton@gmail.com/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants