17
17
#include "argv-array.h"
18
18
#include "utf8.h"
19
19
20
- #define TRANSPORT_SUMMARY (x ) \
21
- (int)(TRANSPORT_SUMMARY_WIDTH + strlen(x) - gettext_width(x)), (x)
22
-
23
20
static const char * const builtin_fetch_usage [] = {
24
21
N_ ("git fetch [<options>] [<repository> [<refspec>...]]" ),
25
22
N_ ("git fetch [<options>] <group>" ),
@@ -569,9 +566,12 @@ static void print_compact(struct strbuf *display,
569
566
570
567
static void format_display (struct strbuf * display , char code ,
571
568
const char * summary , const char * error ,
572
- const char * remote , const char * local )
569
+ const char * remote , const char * local ,
570
+ int summary_width )
573
571
{
574
- strbuf_addf (display , "%c %-*s " , code , TRANSPORT_SUMMARY (summary ));
572
+ int width = (summary_width + strlen (summary ) - gettext_width (summary ));
573
+
574
+ strbuf_addf (display , "%c %-*s " , code , width , summary );
575
575
if (!compact_format )
576
576
print_remote_to_local (display , remote , local );
577
577
else
@@ -583,7 +583,8 @@ static void format_display(struct strbuf *display, char code,
583
583
static int update_local_ref (struct ref * ref ,
584
584
const char * remote ,
585
585
const struct ref * remote_ref ,
586
- struct strbuf * display )
586
+ struct strbuf * display ,
587
+ int summary_width )
587
588
{
588
589
struct commit * current = NULL , * updated ;
589
590
enum object_type type ;
@@ -597,7 +598,7 @@ static int update_local_ref(struct ref *ref,
597
598
if (!oidcmp (& ref -> old_oid , & ref -> new_oid )) {
598
599
if (verbosity > 0 )
599
600
format_display (display , '=' , _ ("[up to date]" ), NULL ,
600
- remote , pretty_ref );
601
+ remote , pretty_ref , summary_width );
601
602
return 0 ;
602
603
}
603
604
@@ -611,7 +612,7 @@ static int update_local_ref(struct ref *ref,
611
612
*/
612
613
format_display (display , '!' , _ ("[rejected]" ),
613
614
_ ("can't fetch in current branch" ),
614
- remote , pretty_ref );
615
+ remote , pretty_ref , summary_width );
615
616
return 1 ;
616
617
}
617
618
@@ -621,7 +622,7 @@ static int update_local_ref(struct ref *ref,
621
622
r = s_update_ref ("updating tag" , ref , 0 );
622
623
format_display (display , r ? '!' : 't' , _ ("[tag update]" ),
623
624
r ? _ ("unable to update local ref" ) : NULL ,
624
- remote , pretty_ref );
625
+ remote , pretty_ref , summary_width );
625
626
return r ;
626
627
}
627
628
@@ -654,7 +655,7 @@ static int update_local_ref(struct ref *ref,
654
655
r = s_update_ref (msg , ref , 0 );
655
656
format_display (display , r ? '!' : '*' , what ,
656
657
r ? _ ("unable to update local ref" ) : NULL ,
657
- remote , pretty_ref );
658
+ remote , pretty_ref , summary_width );
658
659
return r ;
659
660
}
660
661
@@ -670,7 +671,7 @@ static int update_local_ref(struct ref *ref,
670
671
r = s_update_ref ("fast-forward" , ref , 1 );
671
672
format_display (display , r ? '!' : ' ' , quickref .buf ,
672
673
r ? _ ("unable to update local ref" ) : NULL ,
673
- remote , pretty_ref );
674
+ remote , pretty_ref , summary_width );
674
675
strbuf_release (& quickref );
675
676
return r ;
676
677
} else if (force || ref -> force ) {
@@ -685,12 +686,12 @@ static int update_local_ref(struct ref *ref,
685
686
r = s_update_ref ("forced-update" , ref , 1 );
686
687
format_display (display , r ? '!' : '+' , quickref .buf ,
687
688
r ? _ ("unable to update local ref" ) : _ ("forced update" ),
688
- remote , pretty_ref );
689
+ remote , pretty_ref , summary_width );
689
690
strbuf_release (& quickref );
690
691
return r ;
691
692
} else {
692
693
format_display (display , '!' , _ ("[rejected]" ), _ ("non-fast-forward" ),
693
- remote , pretty_ref );
694
+ remote , pretty_ref , summary_width );
694
695
return 1 ;
695
696
}
696
697
}
@@ -721,6 +722,7 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
721
722
char * url ;
722
723
const char * filename = dry_run ? "/dev/null" : git_path_fetch_head ();
723
724
int want_status ;
725
+ int summary_width = TRANSPORT_SUMMARY_WIDTH ;
724
726
725
727
fp = fopen (filename , "a" );
726
728
if (!fp )
@@ -830,13 +832,14 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
830
832
831
833
strbuf_reset (& note );
832
834
if (ref ) {
833
- rc |= update_local_ref (ref , what , rm , & note );
835
+ rc |= update_local_ref (ref , what , rm , & note ,
836
+ summary_width );
834
837
free (ref );
835
838
} else
836
839
format_display (& note , '*' ,
837
840
* kind ? kind : "branch" , NULL ,
838
841
* what ? what : "HEAD" ,
839
- "FETCH_HEAD" );
842
+ "FETCH_HEAD" , summary_width );
840
843
if (note .len ) {
841
844
if (verbosity >= 0 && !shown_url ) {
842
845
fprintf (stderr , _ ("From %.*s\n" ),
@@ -903,6 +906,7 @@ static int prune_refs(struct refspec *refs, int ref_count, struct ref *ref_map,
903
906
int url_len , i , result = 0 ;
904
907
struct ref * ref , * stale_refs = get_stale_heads (refs , ref_count , ref_map );
905
908
char * url ;
909
+ int summary_width = TRANSPORT_SUMMARY_WIDTH ;
906
910
const char * dangling_msg = dry_run
907
911
? _ (" (%s will become dangling)" )
908
912
: _ (" (%s has become dangling)" );
@@ -938,7 +942,8 @@ static int prune_refs(struct refspec *refs, int ref_count, struct ref *ref_map,
938
942
shown_url = 1 ;
939
943
}
940
944
format_display (& sb , '-' , _ ("[deleted]" ), NULL ,
941
- _ ("(none)" ), prettify_refname (ref -> name ));
945
+ _ ("(none)" ), prettify_refname (ref -> name ),
946
+ summary_width );
942
947
fprintf (stderr , " %s\n" ,sb .buf );
943
948
strbuf_release (& sb );
944
949
warn_dangling_symref (stderr , dangling_msg , ref -> name );
0 commit comments