@@ -259,6 +259,7 @@ static void get_correspondences(struct string_list *a, struct string_list *b,
259
259
}
260
260
261
261
static void output_pair_header (struct diff_options * diffopt ,
262
+ int patch_no_width ,
262
263
struct strbuf * buf ,
263
264
struct strbuf * dashes ,
264
265
struct patch_util * a_util ,
@@ -295,9 +296,9 @@ static void output_pair_header(struct diff_options *diffopt,
295
296
strbuf_reset (buf );
296
297
strbuf_addstr (buf , status == '!' ? color_old : color );
297
298
if (!a_util )
298
- strbuf_addf (buf , "- : %s " , dashes -> buf );
299
+ strbuf_addf (buf , "%*s : %s " , patch_no_width , "- " , dashes -> buf );
299
300
else
300
- strbuf_addf (buf , "%d: %s " , a_util -> i + 1 ,
301
+ strbuf_addf (buf , "%* d: %s " , patch_no_width , a_util -> i + 1 ,
301
302
find_unique_abbrev (& a_util -> oid , DEFAULT_ABBREV ));
302
303
303
304
if (status == '!' )
@@ -307,9 +308,9 @@ static void output_pair_header(struct diff_options *diffopt,
307
308
strbuf_addf (buf , "%s%s" , color_reset , color_new );
308
309
309
310
if (!b_util )
310
- strbuf_addf (buf , " - : %s" , dashes -> buf );
311
+ strbuf_addf (buf , " %*s : %s" , patch_no_width , "- " , dashes -> buf );
311
312
else
312
- strbuf_addf (buf , " %d: %s" , b_util -> i + 1 ,
313
+ strbuf_addf (buf , " %* d: %s" , patch_no_width , b_util -> i + 1 ,
313
314
find_unique_abbrev (& b_util -> oid , DEFAULT_ABBREV ));
314
315
315
316
commit = lookup_commit_reference (oid );
@@ -362,6 +363,7 @@ static void output(struct string_list *a, struct string_list *b,
362
363
struct diff_options * diffopt )
363
364
{
364
365
struct strbuf buf = STRBUF_INIT , dashes = STRBUF_INIT ;
366
+ int patch_no_width = decimal_width (1 + (a -> nr > b -> nr ? a -> nr : b -> nr ));
365
367
int i = 0 , j = 0 ;
366
368
367
369
/*
@@ -383,23 +385,23 @@ static void output(struct string_list *a, struct string_list *b,
383
385
384
386
/* Show unmatched LHS commit whose predecessors were shown. */
385
387
if (i < a -> nr && a_util -> matching < 0 ) {
386
- output_pair_header (diffopt ,
388
+ output_pair_header (diffopt , patch_no_width ,
387
389
& buf , & dashes , a_util , NULL );
388
390
i ++ ;
389
391
continue ;
390
392
}
391
393
392
394
/* Show unmatched RHS commits. */
393
395
while (j < b -> nr && b_util -> matching < 0 ) {
394
- output_pair_header (diffopt ,
396
+ output_pair_header (diffopt , patch_no_width ,
395
397
& buf , & dashes , NULL , b_util );
396
398
b_util = ++ j < b -> nr ? b -> items [j ].util : NULL ;
397
399
}
398
400
399
401
/* Show matching LHS/RHS pair. */
400
402
if (j < b -> nr ) {
401
403
a_util = a -> items [b_util -> matching ].util ;
402
- output_pair_header (diffopt ,
404
+ output_pair_header (diffopt , patch_no_width ,
403
405
& buf , & dashes , a_util , b_util );
404
406
if (!(diffopt -> output_format & DIFF_FORMAT_NO_OUTPUT ))
405
407
patch_diff (a -> items [b_util -> matching ].string ,
0 commit comments