]> source.dussan.org Git - gitea.git/commit
Prevent off-by-one error on comments on newly appended lines (#18029) (#18035)
authorzeripath <art27@cantab.net>
Mon, 20 Dec 2021 16:38:58 +0000 (16:38 +0000)
committerGitHub <noreply@github.com>
Mon, 20 Dec 2021 16:38:58 +0000 (11:38 -0500)
commit148a417774f2d063ab31fdce10a7f720e2acd2b8
tree9b38c82ad86fd2cbd4df14f18bcae804539a06cc
parent6081948ef0b9f2c9957b5748a276af9bf947a59d
Prevent off-by-one error on comments on newly appended lines (#18029) (#18035)

* Prevent off-by-one error on comments on newly appended lines (#18029)

Backport #18029

There was a bug in CutDiffAroundLine whereby if a file without a terminal new line
has a patch which appends lines to it and a comment is placed on one of those lines
the comment diff will be a line out of place.

This fixes CutDiffAroundLine to simply ignore the missing terminal newline - however,
we should really improve this rendering to add a marker to say that there was a
previously missing terminal newline.

Fix #17875

Signed-off-by: Andrew Thornton <art27@cantab.net>
* Apply suggestions from code review

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
modules/git/diff.go
modules/git/diff_test.go