@@ -53,7 +53,7 @@ static int diff_file_stats_full_to_buf(
5353 const git_diff_stats * stats ,
5454 size_t width )
5555{
56- const char * old_path = NULL , * new_path = NULL ;
56+ const char * old_path = NULL , * new_path = NULL , * adddel_path = NULL ;
5757 size_t padding ;
5858 git_object_size_t old_size , new_size ;
5959
@@ -62,7 +62,7 @@ static int diff_file_stats_full_to_buf(
6262 old_size = delta -> old_file .size ;
6363 new_size = delta -> new_file .size ;
6464
65- if (strcmp (old_path , new_path ) != 0 ) {
65+ if (old_path && new_path && strcmp (old_path , new_path ) != 0 ) {
6666 size_t common_dirlen ;
6767 int error ;
6868
@@ -82,10 +82,11 @@ static int diff_file_stats_full_to_buf(
8282 if (error < 0 )
8383 goto on_error ;
8484 } else {
85- if (git_buf_printf (out , " %s" , old_path ) < 0 )
85+ adddel_path = new_path ? new_path : old_path ;
86+ if (git_buf_printf (out , " %s" , adddel_path ) < 0 )
8687 goto on_error ;
8788
88- padding = stats -> max_name - strlen (old_path );
89+ padding = stats -> max_name - strlen (adddel_path );
8990
9091 if (stats -> renames > 0 )
9192 padding += strlen (DIFF_RENAME_FILE_SEPARATOR );
@@ -211,7 +212,7 @@ int git_diff_get_stats(
211212
212213 /* TODO ugh */
213214 namelen = strlen (delta -> new_file .path );
214- if (strcmp (delta -> old_file .path , delta -> new_file .path ) != 0 ) {
215+ if (delta -> old_file . path && strcmp (delta -> old_file .path , delta -> new_file .path ) != 0 ) {
215216 namelen += strlen (delta -> old_file .path );
216217 stats -> renames ++ ;
217218 }
0 commit comments