Possible bug with 'diff --cc' report

From: Groboclown <hidden>
Date: 2024-02-13 02:24:17

While testing out the report parser for the gitleaks go-gitdiff
library against a repository, I encountered output in the form:

@@@ -229,4 -229,18446744073709551615 +228,3 @@@ Comment

The '18446744073709551615' value is interesting, in that it's a uint64
value storing a signed int64 -1.  Along with this, the number of
changed lines in the output was actually 5 / 0 / 4 (as opposed to 4 /
-1 / 3).  I found the '-1' value as the first, second, and third line
counts (the code only used at most 2 parents per commit).

At first I thought this to only happen on some 0 line change
instances, but I also found a diff result that looked like (I added a
' mark before each line to make the spacing obvious):

'@@@ -225,4 -237,2 +225,6 @@@ Comment
' +line 1
' +line 2
' +line 3
' +line 4
'- line 5
'++line 6
'++line 7
'+ line 8
' -line 9
' -line 10

The reported line counts doesn't match the actual output.  Based on
other examples plus the documentation, it looks like these are also
off by 1 - by my count, it should be 5 / 3 / 7, rather than 4 / 2 / 6.

System information:

git version 2.43.0
cpu: x86_64
sizeof-long: 8
sizeof-size_t: 8
uname: Linux 5.15.146.1-microsoft-standard-WSL2
compiler info: gnuc: 13.2
libc info: glibc: 2.39
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help