@@ -618,8 +618,8 @@ static void reuse_combine_diff(struct sline *sline, unsigned long cnt,
618
618
sline -> p_lno [i ] = sline -> p_lno [j ];
619
619
}
620
620
621
- int show_combined_diff (struct combine_diff_path * elem , int num_parent ,
622
- int dense , const char * header )
621
+ static int show_patch_diff (struct combine_diff_path * elem , int num_parent ,
622
+ int dense , const char * header )
623
623
{
624
624
unsigned long size , cnt , lno ;
625
625
char * result , * cp , * ep ;
@@ -791,32 +791,69 @@ static void show_raw_diff(struct combine_diff_path *p, int num_parent, const cha
791
791
792
792
if (header )
793
793
puts (header );
794
- offset = strlen (COLONS ) - num_parent ;
795
- if (offset < 0 )
796
- offset = 0 ;
797
- prefix = COLONS + offset ;
798
794
799
- /* Show the modes */
800
795
for (i = 0 ; i < num_parent ; i ++ ) {
801
- int mode = p -> parent [i ].mode ;
802
- if (mode )
796
+ if (p -> parent [i ].mode )
803
797
mod_type = 'M' ;
804
- printf ("%s%06o" , prefix , mode );
805
- prefix = " " ;
806
798
}
807
- printf ("%s%06o" , prefix , p -> mode );
808
799
if (!p -> mode )
809
800
mod_type = 'D' ;
810
801
811
- /* Show sha1's */
812
- for (i = 0 ; i < num_parent ; i ++ ) {
813
- printf ("%s%s" , prefix , diff_unique_abbrev (p -> parent [i ].sha1 , opt -> abbrev ));
814
- prefix = " " ;
802
+ if (opt -> output_format == DIFF_FORMAT_RAW ) {
803
+ offset = strlen (COLONS ) - num_parent ;
804
+ if (offset < 0 )
805
+ offset = 0 ;
806
+ prefix = COLONS + offset ;
807
+
808
+ /* Show the modes */
809
+ for (i = 0 ; i < num_parent ; i ++ ) {
810
+ printf ("%s%06o" , prefix , p -> parent [i ].mode );
811
+ prefix = " " ;
812
+ }
813
+ printf ("%s%06o" , prefix , p -> mode );
814
+
815
+ /* Show sha1's */
816
+ for (i = 0 ; i < num_parent ; i ++ )
817
+ printf (" %s" , diff_unique_abbrev (p -> parent [i ].sha1 ,
818
+ opt -> abbrev ));
819
+ printf (" %s " , diff_unique_abbrev (p -> sha1 , opt -> abbrev ));
820
+ }
821
+
822
+ if (opt -> output_format == DIFF_FORMAT_RAW ||
823
+ opt -> output_format == DIFF_FORMAT_NAME_STATUS )
824
+ printf ("%c%c" , mod_type , inter_name_termination );
825
+
826
+ if (line_termination ) {
827
+ if (quote_c_style (p -> path , NULL , NULL , 0 ))
828
+ quote_c_style (p -> path , NULL , stdout , 0 );
829
+ else
830
+ printf ("%s" , p -> path );
831
+ putchar (line_termination );
832
+ }
833
+ else {
834
+ printf ("%s%c" , p -> path , line_termination );
815
835
}
816
- printf ("%s%s" , prefix , diff_unique_abbrev (p -> sha1 , opt -> abbrev ));
836
+ }
837
+
838
+ int show_combined_diff (struct combine_diff_path * p ,
839
+ int num_parent ,
840
+ int dense ,
841
+ const char * header ,
842
+ struct diff_options * opt )
843
+ {
844
+ if (!p -> len )
845
+ return 0 ;
846
+ switch (opt -> output_format ) {
847
+ case DIFF_FORMAT_RAW :
848
+ case DIFF_FORMAT_NAME_STATUS :
849
+ case DIFF_FORMAT_NAME :
850
+ show_raw_diff (p , num_parent , header , opt );
851
+ return 1 ;
817
852
818
- /* Modification type, terminations, filename */
819
- printf (" %c%c%s%c" , mod_type , inter_name_termination , p -> path , line_termination );
853
+ default :
854
+ case DIFF_FORMAT_PATCH :
855
+ return show_patch_diff (p , num_parent , dense , header );
856
+ }
820
857
}
821
858
822
859
const char * diff_tree_combined_merge (const unsigned char * sha1 ,
@@ -858,14 +895,8 @@ const char *diff_tree_combined_merge(const unsigned char *sha1,
858
895
}
859
896
if (num_paths ) {
860
897
for (p = paths ; p ; p = p -> next ) {
861
- if (!p -> len )
862
- continue ;
863
- if (opt -> output_format == DIFF_FORMAT_RAW ) {
864
- show_raw_diff (p , num_parent , header , opt );
865
- header = NULL ;
866
- continue ;
867
- }
868
- if (show_combined_diff (p , num_parent , dense , header ))
898
+ if (show_combined_diff (p , num_parent , dense ,
899
+ header , opt ))
869
900
header = NULL ;
870
901
}
871
902
}
0 commit comments