@@ -1052,8 +1052,8 @@ static int rerere_forget_one_path(const char *path, struct string_list *rr)
10521052 handle_cache (path , sha1 , rerere_path (id , "thisimage" ));
10531053 if (read_mmfile (& cur , rerere_path (id , "thisimage" ))) {
10541054 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 ;
10571057 }
10581058 cleanly_resolved = !try_merge (id , path , & cur , & result );
10591059 free (result .ptr );
@@ -1062,14 +1062,19 @@ static int rerere_forget_one_path(const char *path, struct string_list *rr)
10621062 break ;
10631063 }
10641064
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+ }
10671069
10681070 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+ };
10731078
10741079 /*
10751080 * 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)
10881093 item -> util = id ;
10891094 fprintf (stderr , "Forgot resolution for %s\n" , path );
10901095 return 0 ;
1096+
1097+ fail_exit :
1098+ free (id );
1099+ return -1 ;
10911100}
10921101
10931102int rerere_forget (struct pathspec * pathspec )
0 commit comments