Commit efff7e0
committed
fix: guard checkDiffFile against mode-only diffs with empty OrigName/NewName
Mode-only diffs (e.g. chmod changes) and some binary diffs produce no
--- / +++ file headers in the unified diff output. The sourcegraph/go-diff
parser therefore returns empty OrigName and NewName strings for those
FileDiff entries. checkDiffFile assumed at least one '/' was always present
(from the 'a/' or 'b/' prefix) and unconditionally accessed index [1] after
SplitN, causing a runtime panic:
panic: runtime error: index out of range [1] with length 1
diff/diff.go:44
Guard the slice length before indexing and skip entries with no file headers
— there is no content to scan in mode-only or header-less diffs.1 parent f707d77 commit efff7e0
1 file changed
Lines changed: 6 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
44 | 49 | | |
45 | 50 | | |
46 | 51 | | |
| |||
90 | 95 | | |
91 | 96 | | |
92 | 97 | | |
93 | | - | |
| 98 | + | |
0 commit comments