@@ -919,7 +919,10 @@ static int gitdiff_hdrend(const char *line, struct patch *patch)
919
919
* their names against any previous information, just
920
920
* to make sure..
921
921
*/
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 )
923
926
{
924
927
if (!orig_name && !isnull )
925
928
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,
934
937
die (_ ("git apply: bad git-diff - expected /dev/null, got %s on line %d" ), name , linenr );
935
938
another = find_name (line , NULL , p_value , TERM_TAB );
936
939
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 );
938
943
free (another );
939
944
return orig_name ;
940
945
}
@@ -949,7 +954,8 @@ static char *gitdiff_verify_name(const char *line, int isnull, char *orig_name,
949
954
static int gitdiff_oldname (const char * line , struct patch * patch )
950
955
{
951
956
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 );
953
959
if (orig != patch -> old_name )
954
960
free (orig );
955
961
return 0 ;
@@ -958,7 +964,8 @@ static int gitdiff_oldname(const char *line, struct patch *patch)
958
964
static int gitdiff_newname (const char * line , struct patch * patch )
959
965
{
960
966
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 );
962
969
if (orig != patch -> new_name )
963
970
free (orig );
964
971
return 0 ;
0 commit comments