@@ -719,35 +719,46 @@ static void update_tracking_ref(struct remote *remote, struct ref *ref, int verb
719
719
720
720
#define SUMMARY_WIDTH (2 * DEFAULT_ABBREV + 3)
721
721
722
- static void print_ref_status (char flag , const char * summary , struct ref * to , struct ref * from , const char * msg )
722
+ static void print_ref_status (char flag , const char * summary , struct ref * to , struct ref * from , const char * msg , int porcelain )
723
723
{
724
- fprintf (stderr , " %c %-*s " , flag , SUMMARY_WIDTH , summary );
725
- if (from )
726
- fprintf (stderr , "%s -> %s" , prettify_refname (from -> name ), prettify_refname (to -> name ));
727
- else
728
- fputs (prettify_refname (to -> name ), stderr );
729
- if (msg ) {
730
- fputs (" (" , stderr );
731
- fputs (msg , stderr );
732
- fputc (')' , stderr );
724
+ if (porcelain ) {
725
+ if (from )
726
+ fprintf (stdout , "%c\t%s:%s\t" , flag , from -> name , to -> name );
727
+ else
728
+ fprintf (stdout , "%c\t:%s\t" , flag , to -> name );
729
+ if (msg )
730
+ fprintf (stdout , "%s (%s)\n" , summary , msg );
731
+ else
732
+ fprintf (stdout , "%s\n" , summary );
733
+ } else {
734
+ fprintf (stderr , " %c %-*s " , flag , SUMMARY_WIDTH , summary );
735
+ if (from )
736
+ fprintf (stderr , "%s -> %s" , prettify_refname (from -> name ), prettify_refname (to -> name ));
737
+ else
738
+ fputs (prettify_refname (to -> name ), stderr );
739
+ if (msg ) {
740
+ fputs (" (" , stderr );
741
+ fputs (msg , stderr );
742
+ fputc (')' , stderr );
743
+ }
744
+ fputc ('\n' , stderr );
733
745
}
734
- fputc ('\n' , stderr );
735
746
}
736
747
737
748
static const char * status_abbrev (unsigned char sha1 [20 ])
738
749
{
739
750
return find_unique_abbrev (sha1 , DEFAULT_ABBREV );
740
751
}
741
752
742
- static void print_ok_ref_status (struct ref * ref )
753
+ static void print_ok_ref_status (struct ref * ref , int porcelain )
743
754
{
744
755
if (ref -> deletion )
745
- print_ref_status ('-' , "[deleted]" , ref , NULL , NULL );
756
+ print_ref_status ('-' , "[deleted]" , ref , NULL , NULL , porcelain );
746
757
else if (is_null_sha1 (ref -> old_sha1 ))
747
758
print_ref_status ('*' ,
748
759
(!prefixcmp (ref -> name , "refs/tags/" ) ? "[new tag]" :
749
- "[new branch]" ),
750
- ref , ref -> peer_ref , NULL );
760
+ "[new branch]" ),
761
+ ref , ref -> peer_ref , NULL , porcelain );
751
762
else {
752
763
char quickref [84 ];
753
764
char type ;
@@ -765,69 +776,70 @@ static void print_ok_ref_status(struct ref *ref)
765
776
}
766
777
strcat (quickref , status_abbrev (ref -> new_sha1 ));
767
778
768
- print_ref_status (type , quickref , ref , ref -> peer_ref , msg );
779
+ print_ref_status (type , quickref , ref , ref -> peer_ref , msg , porcelain );
769
780
}
770
781
}
771
782
772
- static int print_one_push_status (struct ref * ref , const char * dest , int count )
783
+ static int print_one_push_status (struct ref * ref , const char * dest , int count , int porcelain )
773
784
{
774
785
if (!count )
775
786
fprintf (stderr , "To %s\n" , dest );
776
787
777
788
switch (ref -> status ) {
778
789
case REF_STATUS_NONE :
779
- print_ref_status ('X' , "[no match]" , ref , NULL , NULL );
790
+ print_ref_status ('X' , "[no match]" , ref , NULL , NULL , porcelain );
780
791
break ;
781
792
case REF_STATUS_REJECT_NODELETE :
782
793
print_ref_status ('!' , "[rejected]" , ref , NULL ,
783
- "remote does not support deleting refs" );
794
+ "remote does not support deleting refs" , porcelain );
784
795
break ;
785
796
case REF_STATUS_UPTODATE :
786
797
print_ref_status ('=' , "[up to date]" , ref ,
787
- ref -> peer_ref , NULL );
798
+ ref -> peer_ref , NULL , porcelain );
788
799
break ;
789
800
case REF_STATUS_REJECT_NONFASTFORWARD :
790
801
print_ref_status ('!' , "[rejected]" , ref , ref -> peer_ref ,
791
- "non-fast forward" );
802
+ "non-fast forward" , porcelain );
792
803
break ;
793
804
case REF_STATUS_REMOTE_REJECT :
794
805
print_ref_status ('!' , "[remote rejected]" , ref ,
795
- ref -> deletion ? NULL : ref -> peer_ref ,
796
- ref -> remote_status );
806
+ ref -> deletion ? NULL : ref -> peer_ref ,
807
+ ref -> remote_status , porcelain );
797
808
break ;
798
809
case REF_STATUS_EXPECTING_REPORT :
799
810
print_ref_status ('!' , "[remote failure]" , ref ,
800
- ref -> deletion ? NULL : ref -> peer_ref ,
801
- "remote failed to report status" );
811
+ ref -> deletion ? NULL : ref -> peer_ref ,
812
+ "remote failed to report status" , porcelain );
802
813
break ;
803
814
case REF_STATUS_OK :
804
- print_ok_ref_status (ref );
815
+ print_ok_ref_status (ref , porcelain );
805
816
break ;
806
817
}
807
818
808
819
return 1 ;
809
820
}
810
821
811
- static void print_push_status (const char * dest , struct ref * refs , int verbose )
822
+ static void print_push_status (const char * dest , struct ref * refs ,
823
+ int verbose , int porcelain )
812
824
{
813
825
struct ref * ref ;
814
826
int n = 0 ;
815
827
816
828
if (verbose ) {
817
829
for (ref = refs ; ref ; ref = ref -> next )
818
830
if (ref -> status == REF_STATUS_UPTODATE )
819
- n += print_one_push_status (ref , dest , n );
831
+ n += print_one_push_status (ref , dest , n , porcelain );
820
832
}
821
833
822
834
for (ref = refs ; ref ; ref = ref -> next )
823
835
if (ref -> status == REF_STATUS_OK )
824
- n += print_one_push_status (ref , dest , n );
836
+ n += print_one_push_status (ref , dest , n , porcelain );
825
837
826
838
for (ref = refs ; ref ; ref = ref -> next ) {
827
839
if (ref -> status != REF_STATUS_NONE &&
828
840
ref -> status != REF_STATUS_UPTODATE &&
829
841
ref -> status != REF_STATUS_OK )
830
- n += print_one_push_status (ref , dest , n );
842
+ n += print_one_push_status (ref , dest , n , porcelain );
831
843
}
832
844
}
833
845
@@ -997,6 +1009,7 @@ int transport_push(struct transport *transport,
997
1009
struct ref * local_refs = get_local_heads ();
998
1010
int match_flags = MATCH_REFS_NONE ;
999
1011
int verbose = flags & TRANSPORT_PUSH_VERBOSE ;
1012
+ int porcelain = flags & TRANSPORT_PUSH_PORCELAIN ;
1000
1013
int ret ;
1001
1014
1002
1015
if (flags & TRANSPORT_PUSH_ALL )
@@ -1011,7 +1024,7 @@ int transport_push(struct transport *transport,
1011
1024
1012
1025
ret = transport -> push_refs (transport , remote_refs , flags );
1013
1026
1014
- print_push_status (transport -> url , remote_refs , verbose );
1027
+ print_push_status (transport -> url , remote_refs , verbose | porcelain , porcelain );
1015
1028
1016
1029
if (!(flags & TRANSPORT_PUSH_DRY_RUN )) {
1017
1030
struct ref * ref ;
0 commit comments