-
Notifications
You must be signed in to change notification settings - Fork 516
Closed
Description
It looks like the leading line number is off by one in at least this case, where there are no deleted lines, and there is zero context.
Example: (note the hunk header is -1,0 +2,3
$> cat /tmp/a
hello
alice
$> cat /tmp/b
hello
my
name
is
alice
$> diff -U 0 /tmp/a /tmp/b
--- /tmp/a 2020-08-27 18:06:40.000000000 -0700
+++ /tmp/b 2020-08-27 18:06:47.000000000 -0700
@@ -1,0 +2,3 @@
+my
+name
+is
And the same comparison with JsDiff
-- notice the hunk header is -2,0 +2,3
$> node
> const JsDiff = require('diff')
> const fs = require('fs')
> var a = fs.readFileSync('/tmp/a', 'utf8')
> var b = fs.readFileSync('/tmp/b', 'utf8')
> JsDiff.createTwoFilesPatch('a', 'b', a, b, '', '', {'context':0})
'===================================================================\n' +
'--- a\t\n' +
'+++ b\t\n' +
'@@ -2,0 +2,3 @@\n' +
'+my\n' +
'+name\n' +
'+is\n'
Metadata
Metadata
Assignees
Labels
No labels