]> source.dussan.org Git - gitea.git/commit
Fix diff skipping lines (#13157)
authorzeripath <art27@cantab.net>
Fri, 16 Oct 2020 21:09:25 +0000 (22:09 +0100)
committerGitHub <noreply@github.com>
Fri, 16 Oct 2020 21:09:25 +0000 (17:09 -0400)
commite6a82047ee75415befe3f17d88003df138af54ba
tree502ca7fc75e59f8b77540cd3a5108059bc5b05c6
parent99fb2564118286a5fc2db5676b44029a96a14087
Fix diff skipping lines (#13157)

* Fix diff skipping lines

Backport #13154

ParsePatch previously just skipped all lines that start with "+++ " or "--- "
and makes no attempt to see these lines in context.

This PR rewrites ParsePatch to pay attention to context and position
within a patch, ensuring that --- and +++ are only skipped if
appropriate.

This PR also fixes several issues with incomplete files.

Fix https://codeberg.org/Codeberg/Community/issues/308
Fix #13153

Signed-off-by: Andrew Thornton <art27@cantab.net>
* Add testcase

Signed-off-by: Andrew Thornton <art27@cantab.net>
* fix comment

* simplify error handling

Signed-off-by: Andrew Thornton <art27@cantab.net>
* never return io.EOF

Signed-off-by: Andrew Thornton <art27@cantab.net>
services/gitdiff/gitdiff.go
services/gitdiff/gitdiff_test.go