@@ -1052,8 +1052,8 @@ static int rerere_forget_one_path(const char *path, struct string_list *rr)
1052
1052
handle_cache (path , sha1 , rerere_path (id , "thisimage" ));
1053
1053
if (read_mmfile (& cur , rerere_path (id , "thisimage" ))) {
1054
1054
free (cur .ptr );
1055
- return error ("Failed to update conflicted state in '%s'" ,
1056
- path ) ;
1055
+ error ("Failed to update conflicted state in '%s'" , path );
1056
+ goto fail_exit ;
1057
1057
}
1058
1058
cleanly_resolved = !try_merge (id , path , & cur , & result );
1059
1059
free (result .ptr );
@@ -1062,14 +1062,19 @@ static int rerere_forget_one_path(const char *path, struct string_list *rr)
1062
1062
break ;
1063
1063
}
1064
1064
1065
- if (id -> collection -> status_nr <= id -> variant )
1066
- return error ("no remembered resolution for '%s'" , path );
1065
+ if (id -> collection -> status_nr <= id -> variant ) {
1066
+ error ("no remembered resolution for '%s'" , path );
1067
+ goto fail_exit ;
1068
+ }
1067
1069
1068
1070
filename = rerere_path (id , "postimage" );
1069
- if (unlink (filename ))
1070
- return (errno == ENOENT
1071
- ? error ("no remembered resolution for %s" , path )
1072
- : error ("cannot unlink %s: %s" , filename , strerror (errno )));
1071
+ if (unlink (filename )) {
1072
+ if (errno == ENOENT )
1073
+ error ("no remembered resolution for %s" , path );
1074
+ else
1075
+ error ("cannot unlink %s: %s" , filename , strerror (errno ));
1076
+ goto fail_exit ;
1077
+ };
1073
1078
1074
1079
/*
1075
1080
* Update the preimage so that the user can resolve the
@@ -1088,6 +1093,10 @@ static int rerere_forget_one_path(const char *path, struct string_list *rr)
1088
1093
item -> util = id ;
1089
1094
fprintf (stderr , "Forgot resolution for %s\n" , path );
1090
1095
return 0 ;
1096
+
1097
+ fail_exit :
1098
+ free (id );
1099
+ return -1 ;
1091
1100
}
1092
1101
1093
1102
int rerere_forget (struct pathspec * pathspec )
0 commit comments