What does the “…” meta line with at signs in svn diff or git diff mean?
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
Introduction
The line that starts with @@ in git diff or svn diff is the hunk header. It tells you where a block of changes belongs in the old file and in the new file, so both humans and patch tools can understand the edit.
Reading the Hunk Header
A typical unified diff hunk looks like this:
The -12,4 part refers to the original file. It means the hunk starts at line 12 and covers 4 lines of old content.
The +12,6 part refers to the new file. It means the replacement block starts at line 12 and covers 6 lines in the updated version.
The header does not say that every line changed. It marks the range of the chunk, including unchanged context lines that surround the edit.
Why Diff Output Uses Hunks
Diff tools do not usually print the whole file. They print only the changed areas plus a few unchanged lines around each change. Each of those areas is a hunk.
That makes reviews readable and allows patch tools to apply the change later. If the target file shifted a little but the nearby context still matches, the patch can often still be applied.
Here is another example:
This means the edit starts near line 30 in both versions. The old block has 3 lines and the new block also has 3 lines.
What the Prefixes Mean
Inside a hunk, line prefixes matter:
- A space means the line is unchanged context.
- '
-means the line exists only in the old file.' - '
+means the line exists only in the new file.'
Minimal example:
Because one line was removed and one was added, the old and new counts both stay at 2 for that chunk.
Variations You Will See
Sometimes the count is omitted. For example, @@ -5 +5 @@ means one line in each file. The single-line count can be left out because it is implied.
Git may also append a label after the second @@:
That trailing text is just extra context, often a function name or nearby code label. It is there to help the reader, not to change the patch semantics.
File-level headers appear above hunks and serve a different purpose:
Those lines identify the old file and the new file. The @@ line describes the specific changed region within that file pair.
How This Helps When Applying Patches
Patch application depends on the hunk header plus the surrounding context. A patch tool does not blindly insert text at a line number. It uses the header as a guide, then checks whether the nearby context lines still match.
That is why a patch can sometimes apply even if line numbers drift slightly, and why it can fail if the surrounding code changed too much.
You can see the same structure when generating a patch file:
The check step validates whether the hunks can be matched cleanly.
Common Pitfalls
A frequent misunderstanding is reading -12,4 as "four lines were deleted." It actually means the old side of the hunk spans four lines, including unchanged context.
Another mistake is confusing file headers with hunk headers. --- and +++ identify files; @@ identifies one changed chunk inside those files.
People also assume the trailing label after @@ affects how the patch is applied. It does not. It is explanatory text for humans.
Summary
- The
@@ ... @@line is the unified diff hunk header. - '
-start,countdescribes the old file range.' - '
+start,countdescribes the new file range.' - Space,
-, and+prefixes show unchanged, removed, and added lines. - Trailing text after the second
@@is extra context, not patch logic.
Related reading
- What does the exclamation mark mean in git config alias?
- What does the term porcelain mean in Git?
- What effect does the `--no-ff` flag have for `git merge`?
- What effect does the --no-ff flag have for git merge?
- What exactly does git's rebase --preserve-merges do and why?
- What exactly does the u do? git push -u origin master vs git push origin master
- What exactly is a Maven Snapshot and why do we need it?
- What Git branching models work for you?
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.