Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

plumbing: diff, fix crash when a small ending equal-chunk #749

Merged
merged 2 commits into from
Feb 17, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions plumbing/format/diff/unified_encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,15 @@ func (c *hunksGenerator) processEqualsLines(ls []string, i int) {
c.current.AddOp(Equal, c.afterContext...)
c.afterContext = nil
} else {
c.current.AddOp(Equal, c.afterContext[:c.ctxLines]...)
ctxLines := c.ctxLines
if ctxLines > len(c.afterContext) {
ctxLines = len(c.afterContext)
}
c.current.AddOp(Equal, c.afterContext[:ctxLines]...)
c.hunks = append(c.hunks, c.current)

c.current = nil
c.beforeContext = c.afterContext[c.ctxLines:]
c.beforeContext = c.afterContext[ctxLines:]
c.afterContext = nil
}
}
Expand Down