diff options
author | Junio C Hamano <gitster@pobox.com> | 2015-06-30 22:43:37 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-07-24 16:02:31 -0700 |
commit | e828de826bd0b852337b9625354c7c73d8de20c0 (patch) | |
tree | 3832506681fe139f676b9c7e5f40959be4587a9a /rerere.c | |
parent | 963ec003560765bde56a880d89c75056ebe9e990 (diff) | |
download | git-e828de826bd0b852337b9625354c7c73d8de20c0.tar.gz |
rerere: explain the remainder
Explain the internals of rerere as in-code comments, while
sprinkling "NEEDSWORK" comment to highlight iffy bits and
questionable assumptions.
This covers the codepath that implements "rerere gc" and "rerere
clear".
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'rerere.c')
-rw-r--r-- | rerere.c | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -853,6 +853,9 @@ int rerere_forget(struct pathspec *pathspec) return write_rr(&merge_rr, fd); } +/* + * Garbage collection support + */ static time_t rerere_created_at(const char *name) { struct stat st; @@ -865,11 +868,19 @@ static time_t rerere_last_used_at(const char *name) return stat(rerere_path(name, "postimage"), &st) ? (time_t) 0 : st.st_mtime; } +/* + * Remove the recorded resolution for a given conflict ID + */ static void unlink_rr_item(const char *name) { unlink(rerere_path(name, "thisimage")); unlink(rerere_path(name, "preimage")); unlink(rerere_path(name, "postimage")); + /* + * NEEDSWORK: what if this rmdir() fails? Wouldn't we then + * assume that we already have preimage recorded in + * do_plain_rerere()? + */ rmdir(git_path("rr-cache/%s", name)); } @@ -889,6 +900,7 @@ void rerere_gc(struct string_list *rr) dir = opendir(git_path("rr-cache")); if (!dir) die_errno("unable to open rr-cache directory"); + /* Collect stale conflict IDs ... */ while ((e = readdir(dir))) { if (is_dot_or_dotdot(e->d_name)) continue; @@ -906,11 +918,19 @@ void rerere_gc(struct string_list *rr) string_list_append(&to_remove, e->d_name); } closedir(dir); + /* ... and then remove them one-by-one */ for (i = 0; i < to_remove.nr; i++) unlink_rr_item(to_remove.items[i].string); string_list_clear(&to_remove, 0); } +/* + * During a conflict resolution, after "rerere" recorded the + * preimages, abandon them if the user did not resolve them or + * record their resolutions. And drop $GIT_DIR/MERGE_RR. + * + * NEEDSWORK: shouldn't we be calling this from "reset --hard"? + */ void rerere_clear(struct string_list *merge_rr) { int i; |