Explain the internals of rerere as in-code comments, while
sprinkling "NEEDSWORK" comment to highlight iffy bits and
questionable assumptions.
This one covers the codepath reached from rerere(), the primary
interface to the subsystem.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
@ -206,6 +206,21 @@ static int is_cmarker(char *buf, int marker_char, int marker_size)
@@ -206,6 +206,21 @@ static int is_cmarker(char *buf, int marker_char, int marker_size)
return isspace(*buf);
}
/*
* Read contents a file with conflicts, normalize the conflicts
* by (1) discarding the common ancestor version in diff3-style,
* (2) reordering our side and their side so that whichever sorts
* alphabetically earlier comes before the other one, while
* computing the "conflict ID", which is just an SHA-1 hash of
* one side of the conflict, NUL, the other side of the conflict,
* and NUL concatenated together.
*
* Return the number of conflict hunks found.
*
* NEEDSWORK: the logic and theory of operation behind this conflict
* normalization may deserve to be documented somewhere, perhaps in
* Documentation/technical/rerere.txt.
*/
static int handle_path(unsigned char *sha1, struct rerere_io *io, int marker_size)
{
git_SHA_CTX ctx;
@ -276,6 +291,10 @@ static int handle_path(unsigned char *sha1, struct rerere_io *io, int marker_siz
@@ -276,6 +291,10 @@ static int handle_path(unsigned char *sha1, struct rerere_io *io, int marker_siz
return hunk_no;
}
/*
* Scan the path for conflicts, do the "handle_path()" thing above, and
fprintf(stderr, "Recorded resolution for '%s'.\n", path);
mark_resolved:
free(rr->items[i].util);
rr->items[i].util = NULL;
@ -698,6 +762,11 @@ int setup_rerere(struct string_list *merge_rr, int flags)
@@ -698,6 +762,11 @@ int setup_rerere(struct string_list *merge_rr, int flags)
return fd;
}
/*
* The main entry point that is called internally from codepaths that
* perform mergy operations, possibly leaving conflicted index entries