Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
rerere: explain the remainder
author
Junio C Hamano
<gitster@pobox.com>
Wed, 1 Jul 2015 05:43:37 +0000
(22:43 -0700)
committer
Junio C Hamano
<gitster@pobox.com>
Fri, 24 Jul 2015 23:02:31 +0000
(16:02 -0700)
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>
rerere.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (from parent 1:
963ec00
)
diff --git
a/rerere.c
b/rerere.c
index c3e34d10d9bacff099fa7c3fadada324eff0314b..e167670eb4773d5fe3bfec868b8453921efd9fc9 100644
(file)
--- a/
rerere.c
+++ b/
rerere.c
@@
-853,6
+853,9
@@
int rerere_forget(struct pathspec *pathspec)
return write_rr(&merge_rr, fd);
}
return write_rr(&merge_rr, fd);
}
+/*
+ * Garbage collection support
+ */
static time_t rerere_created_at(const char *name)
{
struct stat st;
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;
}
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"));
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));
}
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");
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;
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);
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);
}
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;
void rerere_clear(struct string_list *merge_rr)
{
int i;