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