@@ -921,21 +921,15 @@ static int check_filenames(git_patch_parsed *patch)
921921 return git_parse_err ("missing old path" );
922922
923923 /* Ensure (non-renamed) paths match */
924- if (check_header_names (
925- patch -> header_old_path , patch -> old_path , "old" , added ) < 0 ||
926- check_header_names (
927- patch -> header_new_path , patch -> new_path , "new" , deleted ) < 0 )
924+ if (check_header_names (patch -> header_old_path , patch -> old_path , "old" , added ) < 0 ||
925+ check_header_names (patch -> header_new_path , patch -> new_path , "new" , deleted ) < 0 )
928926 return -1 ;
929927
930- prefixed_old = (!added && patch -> old_path ) ? patch -> old_path :
931- patch -> header_old_path ;
932- prefixed_new = (!deleted && patch -> new_path ) ? patch -> new_path :
933- patch -> header_new_path ;
928+ prefixed_old = (!added && patch -> old_path ) ? patch -> old_path : patch -> header_old_path ;
929+ prefixed_new = (!deleted && patch -> new_path ) ? patch -> new_path : patch -> header_new_path ;
934930
935- if (check_prefix (
936- & patch -> old_prefix , & old_prefixlen , patch , prefixed_old ) < 0 ||
937- check_prefix (
938- & patch -> new_prefix , & new_prefixlen , patch , prefixed_new ) < 0 )
931+ if ((prefixed_old && check_prefix (& patch -> old_prefix , & old_prefixlen , patch , prefixed_old ) < 0 ) ||
932+ (prefixed_new && check_prefix (& patch -> new_prefix , & new_prefixlen , patch , prefixed_new ) < 0 ))
939933 return -1 ;
940934
941935 /* Prefer the rename filenames as they are unambiguous and unprefixed */
@@ -950,7 +944,7 @@ static int check_filenames(git_patch_parsed *patch)
950944 patch -> base .delta -> new_file .path = prefixed_new + new_prefixlen ;
951945
952946 if (!patch -> base .delta -> old_file .path &&
953- !patch -> base .delta -> new_file .path )
947+ !patch -> base .delta -> new_file .path )
954948 return git_parse_err ("git diff header lacks old / new paths" );
955949
956950 return 0 ;
@@ -964,14 +958,14 @@ static int check_patch(git_patch_parsed *patch)
964958 return -1 ;
965959
966960 if (delta -> old_file .path &&
967- delta -> status != GIT_DELTA_DELETED &&
968- !delta -> new_file .mode )
961+ delta -> status != GIT_DELTA_DELETED &&
962+ !delta -> new_file .mode )
969963 delta -> new_file .mode = delta -> old_file .mode ;
970964
971965 if (delta -> status == GIT_DELTA_MODIFIED &&
972- !(delta -> flags & GIT_DIFF_FLAG_BINARY ) &&
973- delta -> new_file .mode == delta -> old_file .mode &&
974- git_array_size (patch -> base .hunks ) == 0 )
966+ !(delta -> flags & GIT_DIFF_FLAG_BINARY ) &&
967+ delta -> new_file .mode == delta -> old_file .mode &&
968+ git_array_size (patch -> base .hunks ) == 0 )
975969 return git_parse_err ("patch with no hunks" );
976970
977971 if (delta -> status == GIT_DELTA_ADDED ) {
0 commit comments