@@ -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 (the_repository , oid );
@@ -357,6 +358,7 @@ static void output(struct string_list *a, struct string_list *b,
357
358
struct diff_options * diffopt )
358
359
{
359
360
struct strbuf buf = STRBUF_INIT , dashes = STRBUF_INIT ;
361
+ int patch_no_width = decimal_width (1 + (a -> nr > b -> nr ? a -> nr : b -> nr ));
360
362
int i = 0 , j = 0 ;
361
363
362
364
/*
@@ -378,23 +380,23 @@ static void output(struct string_list *a, struct string_list *b,
378
380
379
381
/* Show unmatched LHS commit whose predecessors were shown. */
380
382
if (i < a -> nr && a_util -> matching < 0 ) {
381
- output_pair_header (diffopt ,
383
+ output_pair_header (diffopt , patch_no_width ,
382
384
& buf , & dashes , a_util , NULL );
383
385
i ++ ;
384
386
continue ;
385
387
}
386
388
387
389
/* Show unmatched RHS commits. */
388
390
while (j < b -> nr && b_util -> matching < 0 ) {
389
- output_pair_header (diffopt ,
391
+ output_pair_header (diffopt , patch_no_width ,
390
392
& buf , & dashes , NULL , b_util );
391
393
b_util = ++ j < b -> nr ? b -> items [j ].util : NULL ;
392
394
}
393
395
394
396
/* Show matching LHS/RHS pair. */
395
397
if (j < b -> nr ) {
396
398
a_util = a -> items [b_util -> matching ].util ;
397
- output_pair_header (diffopt ,
399
+ output_pair_header (diffopt , patch_no_width ,
398
400
& buf , & dashes , a_util , b_util );
399
401
if (!(diffopt -> output_format & DIFF_FORMAT_NO_OUTPUT ))
400
402
patch_diff (a -> items [b_util -> matching ].string ,
0 commit comments