@@ -919,7 +919,10 @@ static int gitdiff_hdrend(const char *line, struct patch *patch)
919919 * their names against any previous information, just
920920 * to make sure..
921921 */
922- static char * gitdiff_verify_name (const char * line , int isnull , char * orig_name , const char * oldnew )
922+ #define DIFF_OLD_NAME 0
923+ #define DIFF_NEW_NAME 1
924+
925+ static char * gitdiff_verify_name (const char * line , int isnull , char * orig_name , int side )
923926{
924927 if (!orig_name && !isnull )
925928 return find_name (line , NULL , p_value , TERM_TAB );
@@ -934,7 +937,9 @@ static char *gitdiff_verify_name(const char *line, int isnull, char *orig_name,
934937 die (_ ("git apply: bad git-diff - expected /dev/null, got %s on line %d" ), name , linenr );
935938 another = find_name (line , NULL , p_value , TERM_TAB );
936939 if (!another || memcmp (another , name , len + 1 ))
937- die (_ ("git apply: bad git-diff - inconsistent %s filename on line %d" ), oldnew , linenr );
940+ die ((side == DIFF_NEW_NAME ) ?
941+ _ ("git apply: bad git-diff - inconsistent new filename on line %d" ) :
942+ _ ("git apply: bad git-diff - inconsistent old filename on line %d" ), linenr );
938943 free (another );
939944 return orig_name ;
940945 }
@@ -949,7 +954,8 @@ static char *gitdiff_verify_name(const char *line, int isnull, char *orig_name,
949954static int gitdiff_oldname (const char * line , struct patch * patch )
950955{
951956 char * orig = patch -> old_name ;
952- patch -> old_name = gitdiff_verify_name (line , patch -> is_new , patch -> old_name , "old" );
957+ patch -> old_name = gitdiff_verify_name (line , patch -> is_new , patch -> old_name ,
958+ DIFF_OLD_NAME );
953959 if (orig != patch -> old_name )
954960 free (orig );
955961 return 0 ;
@@ -958,7 +964,8 @@ static int gitdiff_oldname(const char *line, struct patch *patch)
958964static int gitdiff_newname (const char * line , struct patch * patch )
959965{
960966 char * orig = patch -> new_name ;
961- patch -> new_name = gitdiff_verify_name (line , patch -> is_delete , patch -> new_name , "new" );
967+ patch -> new_name = gitdiff_verify_name (line , patch -> is_delete , patch -> new_name ,
968+ DIFF_NEW_NAME );
962969 if (orig != patch -> new_name )
963970 free (orig );
964971 return 0 ;
0 commit comments