diff options
author | Junio C Hamano <gitster@pobox.com> | 2010-09-01 13:57:23 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2010-09-01 13:57:23 -0700 |
commit | c7f649a794250ca680569bd8c2466af42acb434a (patch) | |
tree | 25e2df69993bb180b1785cb2577cc2cc2ca62ca7 /builtin | |
parent | e4f8fce5c18c9544d3f1a07929fc14e7cbddbcc3 (diff) | |
parent | 7d7ff15b39abfa9e73b6475f189006a74dc26376 (diff) | |
download | git-c7f649a794250ca680569bd8c2466af42acb434a.tar.gz git-c7f649a794250ca680569bd8c2466af42acb434a.tar.xz |
Merge branch 'sg/rerere-gc-old-still-used' into maint
* sg/rerere-gc-old-still-used:
rerere: fix overeager gc
mingw_utime(): handle NULL times parameter
Diffstat (limited to 'builtin')
-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 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); } |