X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=builtin%2Frerere.c;h=0c7202eb9e637b69bcbbf3641d8ed72f44fd7684;hb=af6c6e0b19dc396849e7e09727044ba1a725e811;hp=39ad60169d6f4cd53e560e922410b48cc01f7886;hpb=33a0292e612915320e56f392b3372589f602a9e6;p=git.git diff --git a/builtin/rerere.c b/builtin/rerere.c index 39ad60169..0c7202eb9 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(&to_remove, e->d_name); }