mirror of
https://github.com/go-gitea/gitea.git
synced 2026-08-01 13:19:03 +00:00
Fixes a `runtime error: index out of range [0] with length 0` panic when executing template `repo/diff/section_unified` because `GetLineTypeMarker()` indexes into empty `DiffLine` content. The regression was introduced in PR #38706 (`94c61137e4`) where `Content: " "` was removed from the initialization of `tailDiffLine`. Guarding `GetLineTypeMarker()` directly makes Gitea defensive and robust against empty diff line values regardless of the source path. Fixes https://github.com/go-gitea/gitea/issues/38724 ### Tests - Added `TestDiffLine_GetLineTypeMarker` covering empty content, prefixes, and normal text formats. Signed-off-by: Sudhanshu Singh <sudhanshuwriterblc@gmail.com>