@@ -21,25 +21,26 @@ scanner_debug [OPTIONS] [FILE]
2121### Options
2222
2323- ` -h, --help ` - Show help message
24- - ` -v, --verbose ` - Show verbose output with positions and details
25- - ` -c, --content ` - Show content samples for events
26- - ` -p, --positions ` - Show file positions for all events
24+ - ` -v, --verbose ` - Use multi-line output instead of compact
25+ - ` -c, --content ` - Show content samples for events (verbose mode)
26+ - ` -p, --positions ` - Show file positions for all events (verbose mode)
27+ - ` -x, --extra ` - Show extra details like Git metadata (verbose mode)
2728- ` --color ` - Use colored output (great for terminals)
2829
2930### Examples
3031
3132``` bash
3233# Basic usage
33- scanner_debug patch.diff
34+ scanner_debug example.patch
3435
3536# Colored output with content samples
36- scanner_debug --color --content complex .patch
37+ scanner_debug --color --content example .patch
3738
3839# Debug from stdin
3940diff -u old new | scanner_debug --verbose
4041
4142# Debug context diffs with full details
42- scanner_debug --color --content --verbose context .patch
43+ scanner_debug --color --verbose -- content --extra example .patch
4344```
4445
4546## Event Types
@@ -62,7 +63,10 @@ Individual patch lines with type and context:
6263- ** Removed ('-')** : Removed lines (context: both)
6364- ** Changed ('!')** : Changed lines (context diffs only)
6465 - Emitted twice: first as context "old", then as context "new"
65- - Same line content, different context indicating old vs new version
66+ - Different line content: old version first, then new version
67+ - ** No Newline ('\\ ')** : No newline marker lines (context: both)
68+
69+ ** Note** : "context: both" means the line applies to both old and new file versions conceptually. Only changed lines ('!') in context diffs get special context handling (old/new).
6670
6771### BINARY
6872Binary patch markers (` Binary files differ ` , ` GIT binary patch ` )
@@ -84,38 +88,185 @@ scanner_debug --content context_with_empty.patch | grep "HUNK_LINE.*--.*----"
8488
8589### Understand Git Diff Parsing
8690``` bash
87- scanner_debug --verbose --color git_extended .patch
91+ scanner_debug --verbose --color --extra example .patch
8892# Shows Git metadata parsing and type detection
8993```
9094
9195### Debug Complex Patches
9296``` bash
93- scanner_debug --color --content --verbose complex_series .patch > debug.log
97+ scanner_debug --color --verbose -- content --extra example .patch > debug.log
9498# Full event trace for complex multi-file patches
9599```
96100
97101## Output Format
98102
103+ For the following example patch:
104+ ``` diff
105+ --- old.txt 2024-01-01 12:00:00.000000000 +0000
106+ +++ new.txt 2024-01-01 12:01:00.000000000 +0000
107+ @@ -1,4 +1,4 @@
108+ line1
109+ - old line
110+ + new line
111+ line3
112+ line4
113+ ```
114+
115+ ### Compact Mode (default)
116+ ```
117+ Scanner Debug Output for: example.patch
118+ ================================================================
119+ 2 HEADERS Unified: old.txt → new.txt
120+ 3 HUNK_HEADER -1,4 +1,4
121+ 4 HUNK_LINE line1
122+ 5 HUNK_LINE -old line
123+ 6 HUNK_LINE +new line
124+ 7 HUNK_LINE line3
125+ 8 HUNK_LINE line4
126+ ================================================================
127+ Summary: Processed 7 events, scanner finished normally
128+ ```
129+
130+ ### Verbose Mode (-v/--verbose)
99131```
100132Scanner Debug Output for: example.patch
101133================================================================
102- [HEADERS] HEADERS (line 1, pos 0)
134+ [HEADERS]
103135 Type: Unified
104136 Old: old.txt
105137 New: new.txt
106138
107- [HUNK_HEADER] HUNK_HEADER (line 3, pos 25)
108- Range: -1,3 +1,3
139+ [HUNK_HEADER]
140+ Range: -1,4 +1,4
141+
142+ [HUNK_LINE]
143+ Type: Context (' ') Context: both
144+
145+ [HUNK_LINE]
146+ Type: Removed ('-') Context: both
109147
110- [HUNK_LINE] HUNK_LINE (line 4, pos 38)
111- Type: Context (' ') Context: both Content: "line1\n"
148+ [HUNK_LINE]
149+ Type: Added ('+ ') Context: both
112150
113- [HUNK_LINE] HUNK_LINE (line 5, pos 45)
114- Type: Removed ('-') Context: both Content: "old line\n"
151+ [HUNK_LINE]
152+ Type: Context (' ') Context: both
153+
154+ [HUNK_LINE]
155+ Type: Context (' ') Context: both
115156
116157================================================================
117- Summary: Processed 6 events, scanner finished normally
158+ Summary: Processed 7 events, scanner finished normally
159+ ```
160+
161+ ### Verbose Mode with Content (--verbose --content)
118162```
163+ Scanner Debug Output for: example.patch
164+ ================================================================
165+ [HEADERS]
166+ Type: Unified
167+ Old: old.txt
168+ New: new.txt
169+
170+ [HUNK_HEADER]
171+ Range: -1,4 +1,4
172+
173+ [HUNK_LINE]
174+ Type: Context (' ') Context: both Content: "line1"
175+
176+ [HUNK_LINE]
177+ Type: Removed ('-') Context: both Content: "old line"
178+
179+ [HUNK_LINE]
180+ Type: Added ('+') Context: both Content: "new line"
181+
182+ [HUNK_LINE]
183+ Type: Context (' ') Context: both Content: "line3"
184+
185+ [HUNK_LINE]
186+ Type: Context (' ') Context: both Content: "line4"
187+
188+ ================================================================
189+ Summary: Processed 7 events, scanner finished normally
190+ ```
191+
192+ ## Context Diff Example
193+
194+ For comparison, here's the same patch in context format (converted using ` filterdiff --format=context ` ):
195+ ``` diff
196+ *** old.txt 2024-01-01 12:00:00.000000000 +0000
197+ --- new.txt 2024-01-01 12:01:00.000000000 +0000
198+ ***************
199+ *** 1,4 ****
200+ line1
201+ ! old line
202+ line3
203+ line4
204+ --- 1,4 ----
205+ line1
206+ ! new line
207+ line3
208+ line4
209+ ```
210+
211+ ### Context Diff - Compact Mode
212+ ```
213+ Scanner Debug Output for: example-context.patch
214+ ================================================================
215+ 2 HEADERS Context: old.txt → new.txt
216+ 4 HUNK_HEADER -1,4 +1,4
217+ 9 HUNK_LINE line1
218+ 9 HUNK_LINE ! old line
219+ 9 HUNK_LINE line3
220+ 9 HUNK_LINE line4
221+ 10 HUNK_LINE line1
222+ 11 HUNK_LINE ! new line
223+ 12 HUNK_LINE line3
224+ 13 HUNK_LINE line4
225+ ================================================================
226+ Summary: Processed 10 events, scanner finished normally
227+ ```
228+
229+ ### Context Diff - Verbose Mode with Content
230+ ```
231+ Scanner Debug Output for: example-context.patch
232+ ================================================================
233+ [HEADERS]
234+ Type: Context
235+ Old: old.txt
236+ New: new.txt
237+
238+ [HUNK_HEADER]
239+ Range: -1,4 +1,4
240+
241+ [HUNK_LINE]
242+ Type: Context (' ') Context: both Content: "line1"
243+
244+ [HUNK_LINE]
245+ Type: Changed ('!') Context: old Content: "old line"
246+
247+ [HUNK_LINE]
248+ Type: Context (' ') Context: both Content: "line3"
249+
250+ [HUNK_LINE]
251+ Type: Context (' ') Context: both Content: "line4"
252+
253+ [HUNK_LINE]
254+ Type: Context (' ') Context: both Content: "line1"
255+
256+ [HUNK_LINE]
257+ Type: Changed ('!') Context: new Content: "new line"
258+
259+ [HUNK_LINE]
260+ Type: Context (' ') Context: both Content: "line3"
261+
262+ [HUNK_LINE]
263+ Type: Context (' ') Context: both Content: "line4"
264+
265+ ================================================================
266+ Summary: Processed 10 events, scanner finished normally
267+ ```
268+
269+ ** Note** : In context diffs, changed lines (` ! ` ) are emitted twice - first with the old content (context: old), then with the new content (context: new). This demonstrates the dual emission behavior described earlier.
119270
120271## Color Coding
121272
0 commit comments