diff options
author | SZEDER Gábor <szeder@ira.uka.de> | 2010-07-13 01:42:04 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2010-07-14 09:26:57 -0700 |
commit | 7d7ff15b39abfa9e73b6475f189006a74dc26376 (patch) | |
tree | 2607517d6a25a30d2163148b8d4bf9cf1722069f /builtin/rerere.c | |
parent | ded2d47668c8e865465a7ad69665696f9b56f24b (diff) | |
download | git-7d7ff15b39abfa9e73b6475f189006a74dc26376.tar.gz |
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>
Diffstat (limited to 'builtin/rerere.c')
-rw-r--r-- | builtin/rerere.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/builtin/rerere.c b/builtin/rerere.c index 0048f9ef7f..6d1b5802ad 100644 --- a/builtin/rerere.c +++ b/builtin/rerere.c @@ -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); } |