rerere: fix overeager gc
'rerere gc' prunes resolutions of conflicted merges that occurred long time ago, and when doing so it takes the creation time of the conflicted automerge results into account. This can cause the loss of frequently used conflict resolutions (e.g. long-living topic branches are merged into a regularly rebuilt integration branch (think of git's pu)) when they become old enough to exceed 'rerere gc's threshold. To prevent the loss of valuable merge resolutions 'rerere' will (1) update the timestamp of the recorded conflict resolution (i.e. 'postimage') each time when encountering and resolving the same merge conflict, and (2) take this timestamp, i.e. the time of the last usage into account when gc'ing. Signed-off-by: SZEDER Gábor <szeder@ira.uka.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
ded2d47668
commit
7d7ff15b39
@ -19,6 +19,12 @@ static time_t rerere_created_at(const char *name)
|
||||
return stat(rerere_path(name, "preimage"), &st) ? (time_t) 0 : st.st_mtime;
|
||||
}
|
||||
|
||||
static time_t rerere_last_used_at(const char *name)
|
||||
{
|
||||
struct stat st;
|
||||
return stat(rerere_path(name, "postimage"), &st) ? (time_t) 0 : st.st_mtime;
|
||||
}
|
||||
|
||||
static void unlink_rr_item(const char *name)
|
||||
{
|
||||
unlink(rerere_path(name, "thisimage"));
|
||||
@ -53,11 +59,16 @@ static void garbage_collect(struct string_list *rr)
|
||||
while ((e = readdir(dir))) {
|
||||
if (is_dot_or_dotdot(e->d_name))
|
||||
continue;
|
||||
then = rerere_created_at(e->d_name);
|
||||
if (!then)
|
||||
continue;
|
||||
cutoff = (has_rerere_resolution(e->d_name)
|
||||
? cutoff_resolve : cutoff_noresolve);
|
||||
|
||||
then = rerere_last_used_at(e->d_name);
|
||||
if (then) {
|
||||
cutoff = cutoff_resolve;
|
||||
} else {
|
||||
then = rerere_created_at(e->d_name);
|
||||
if (!then)
|
||||
continue;
|
||||
cutoff = cutoff_noresolve;
|
||||
}
|
||||
if (then < now - cutoff * 86400)
|
||||
string_list_append(e->d_name, &to_remove);
|
||||
}
|
||||
|
Reference in New Issue
Block a user