@@ -344,38 +344,43 @@ struct combine_diff_state {
344
344
struct sline * lost_bucket ;
345
345
};
346
346
347
- static void consume_line (void * state_ , char * line , unsigned long len )
347
+ static void consume_hunk (void * state_ ,
348
+ long ob , long on ,
349
+ long nb , long nn ,
350
+ const char * funcline , long funclen )
348
351
{
349
352
struct combine_diff_state * state = state_ ;
350
- if (5 < len && !memcmp ("@@ -" , line , 4 )) {
351
- if (parse_hunk_header (line , len ,
352
- & state -> ob , & state -> on ,
353
- & state -> nb , & state -> nn ))
354
- return ;
355
- state -> lno = state -> nb ;
356
- if (state -> nn == 0 ) {
357
- /* @@ -X,Y +N,0 @@ removed Y lines
358
- * that would have come *after* line N
359
- * in the result. Our lost buckets hang
360
- * to the line after the removed lines,
361
- *
362
- * Note that this is correct even when N == 0,
363
- * in which case the hunk removes the first
364
- * line in the file.
365
- */
366
- state -> lost_bucket = & state -> sline [state -> nb ];
367
- if (!state -> nb )
368
- state -> nb = 1 ;
369
- } else {
370
- state -> lost_bucket = & state -> sline [state -> nb - 1 ];
371
- }
372
- if (!state -> sline [state -> nb - 1 ].p_lno )
373
- state -> sline [state -> nb - 1 ].p_lno =
374
- xcalloc (state -> num_parent ,
375
- sizeof (unsigned long ));
376
- state -> sline [state -> nb - 1 ].p_lno [state -> n ] = state -> ob ;
377
- return ;
353
+
354
+ state -> ob = ob ;
355
+ state -> on = on ;
356
+ state -> nb = nb ;
357
+ state -> nn = nn ;
358
+ state -> lno = state -> nb ;
359
+ if (state -> nn == 0 ) {
360
+ /* @@ -X,Y +N,0 @@ removed Y lines
361
+ * that would have come *after* line N
362
+ * in the result. Our lost buckets hang
363
+ * to the line after the removed lines,
364
+ *
365
+ * Note that this is correct even when N == 0,
366
+ * in which case the hunk removes the first
367
+ * line in the file.
368
+ */
369
+ state -> lost_bucket = & state -> sline [state -> nb ];
370
+ if (!state -> nb )
371
+ state -> nb = 1 ;
372
+ } else {
373
+ state -> lost_bucket = & state -> sline [state -> nb - 1 ];
378
374
}
375
+ if (!state -> sline [state -> nb - 1 ].p_lno )
376
+ state -> sline [state -> nb - 1 ].p_lno =
377
+ xcalloc (state -> num_parent , sizeof (unsigned long ));
378
+ state -> sline [state -> nb - 1 ].p_lno [state -> n ] = state -> ob ;
379
+ }
380
+
381
+ static void consume_line (void * state_ , char * line , unsigned long len )
382
+ {
383
+ struct combine_diff_state * state = state_ ;
379
384
if (!state -> lost_bucket )
380
385
return ; /* not in any hunk yet */
381
386
switch (line [0 ]) {
@@ -419,8 +424,8 @@ static void combine_diff(const struct object_id *parent, unsigned int mode,
419
424
state .num_parent = num_parent ;
420
425
state .n = n ;
421
426
422
- if (xdi_diff_outf (& parent_file , result_file , NULL , consume_line ,
423
- & state , & xpp , & xecfg ))
427
+ if (xdi_diff_outf (& parent_file , result_file , consume_hunk ,
428
+ consume_line , & state , & xpp , & xecfg ))
424
429
die ("unable to generate combined diff for %s" ,
425
430
oid_to_hex (parent ));
426
431
free (parent_file .ptr );
0 commit comments