summaryrefslogtreecommitdiff
path: root/builtin/rerere.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2010-08-31 23:14:27 (GMT)
committerJunio C Hamano <gitster@pobox.com>2010-08-31 23:14:27 (GMT)
commite24058f57f4e76e38e20390c5927590f3cd48085 (patch)
treed8f9b7149447d6d1be6ea847b807d247d3356fd4 /builtin/rerere.c
parentd8a94803842989582989fd5f5c3062c49134ad5b (diff)
parent7d7ff15b39abfa9e73b6475f189006a74dc26376 (diff)
downloadgit-e24058f57f4e76e38e20390c5927590f3cd48085.zip
git-e24058f57f4e76e38e20390c5927590f3cd48085.tar.gz
git-e24058f57f4e76e38e20390c5927590f3cd48085.tar.bz2
Merge branch 'sg/rerere-gc-old-still-used'
* sg/rerere-gc-old-still-used: rerere: fix overeager gc mingw_utime(): handle NULL times parameter
Diffstat (limited to 'builtin/rerere.c')
-rw-r--r--builtin/rerere.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/builtin/rerere.c b/builtin/rerere.c
index 9b1e3a7..67793fa 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);
}