@@ -422,6 +422,10 @@ static int handle_cache(const char *path, unsigned char *sha1, const char *outpu
422
422
strbuf_init (& io .input , 0 );
423
423
strbuf_attach (& io .input , result .ptr , result .size , result .size );
424
424
425
+ /*
426
+ * Grab the conflict ID and optionally write the original
427
+ * contents with conflict markers out.
428
+ */
425
429
hunk_no = handle_path (sha1 , (struct rerere_io * )& io , marker_size );
426
430
strbuf_release (& io .input );
427
431
if (io .io .output )
@@ -786,19 +790,34 @@ static int rerere_forget_one_path(const char *path, struct string_list *rr)
786
790
int ret ;
787
791
struct string_list_item * item ;
788
792
793
+ /*
794
+ * Recreate the original conflict from the stages in the
795
+ * index and compute the conflict ID
796
+ */
789
797
ret = handle_cache (path , sha1 , NULL );
790
798
if (ret < 1 )
791
799
return error ("Could not parse conflict hunks in '%s'" , path );
800
+
801
+ /* Nuke the recorded resolution for the conflict */
792
802
hex = xstrdup (sha1_to_hex (sha1 ));
793
803
filename = rerere_path (hex , "postimage" );
794
804
if (unlink (filename ))
795
805
return (errno == ENOENT
796
806
? error ("no remembered resolution for %s" , path )
797
807
: error ("cannot unlink %s: %s" , filename , strerror (errno )));
798
808
809
+ /*
810
+ * Update the preimage so that the user can resolve the
811
+ * conflict in the working tree, run us again to record
812
+ * the postimage.
813
+ */
799
814
handle_cache (path , sha1 , rerere_path (hex , "preimage" ));
800
815
fprintf (stderr , "Updated preimage for '%s'\n" , path );
801
816
817
+ /*
818
+ * And remember that we can record resolution for this
819
+ * conflict when the user is done.
820
+ */
802
821
item = string_list_insert (rr , path );
803
822
free (item -> util );
804
823
item -> util = hex ;
@@ -817,6 +836,11 @@ int rerere_forget(struct pathspec *pathspec)
817
836
818
837
fd = setup_rerere (& merge_rr , RERERE_NOAUTOUPDATE );
819
838
839
+ /*
840
+ * The paths may have been resolved (incorrectly);
841
+ * recover the original conflicted state and then
842
+ * find the conflicted paths.
843
+ */
820
844
unmerge_cache (pathspec );
821
845
find_conflict (& conflict );
822
846
for (i = 0 ; i < conflict .nr ; i ++ ) {
0 commit comments