Sample Header Ad - 728x90

How shall I understand the unified format of diff output?

18 votes
1 answer
23399 views
From diffutils' manual > Next come one or more hunks of diff erences; each hunk shows one area > where the files differ. Unified format hunks look like this: > > @@ from-file-line-numbers to-file-line-numbers @@ > line-from-either-file > line-from-either-file... > > **If a hunk contains just one line**, only its start line number appears. > **Otherwise** its line numbers look like ‘start,count’. An empty hunk is > considered to start at the line that follows the hunk. > > **If a hunk and its context contain two or more lines**, its line numbers > look like ‘start,count’. **Otherwise** only its end line number appears. > An empty hunk is considered to end at the line that precedes the hunk. What do they mean? Could you also give some examples to show what they mean? In particular, I couldn't tell the differences between the cases in the last two paragraphs. They seem to talk about the same cases but I suspect they don't. - What is the difference between the "if" case in the first paragraph and the "otherwise" case in the second? - What is the difference between the "otherwise" case in the first paragraph and the "if" case in the second?
Asked by Tim (106420 rep)
Nov 7, 2018, 08:07 PM
Last activity: Jul 25, 2022, 09:45 PM