aboutsummaryrefslogtreecommitdiff
path: root/git-rerere.perl
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2006-12-08 13:03:12 -0800
committerJunio C Hamano <junkio@cox.net>2006-12-09 11:13:17 -0800
commitcda2d3c112a03079af9019c7d6617e65ab88ae7e (patch)
treeed268cd5dc9469feabae431764f1bcd8b8ed0681 /git-rerere.perl
parentd9671b75ad3bbf2f95f11a8571e9beaa12ccf6dd (diff)
downloadgit-cda2d3c112a03079af9019c7d6617e65ab88ae7e.tar.gz
git-cda2d3c112a03079af9019c7d6617e65ab88ae7e.tar.xz
git-rerere: add 'gc' command.
Over time, unresolved rr-cache entries are accumulated and they tend to get less and less likely to be useful as the tips of branches advance. Reorder documentation page to show the subcommand section earlier than the discussion section. Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'git-rerere.perl')
-rwxr-xr-xgit-rerere.perl25
1 files changed, 25 insertions, 0 deletions
diff --git a/git-rerere.perl b/git-rerere.perl
index b2550bb2e..61eef575d 100755
--- a/git-rerere.perl
+++ b/git-rerere.perl
@@ -169,6 +169,28 @@ sub merge {
return 0;
}
+sub garbage_collect_rerere {
+ # We should allow specifying these from the command line and
+ # that is why the caller gives @ARGV to us, but I am lazy.
+
+ my $cutoff_noresolve = 15; # two weeks
+ my $cutoff_resolve = 60; # two months
+ my @to_remove;
+ while (<$rr_dir/*/preimage>) {
+ my ($dir) = /^(.*)\/preimage$/;
+ my $cutoff = ((-f "$dir/postimage")
+ ? $cutoff_resolve
+ : $cutoff_noresolve);
+ my $age = -M "$_";
+ if ($cutoff <= $age) {
+ push @to_remove, $dir;
+ }
+ }
+ if (@to_remove) {
+ rmtree(\@to_remove);
+ }
+}
+
-d "$rr_dir" || exit(0);
read_rr();
@@ -198,6 +220,9 @@ if (@ARGV) {
"$rr_dir/$name/preimage", $path);
}
}
+ elsif ($arg eq 'gc') {
+ garbage_collect_rerere(@ARGV);
+ }
else {
die "$0 unknown command: $arg\n";
}