diff options
Diffstat (limited to 'git-rerere.perl')
-rwxr-xr-x | git-rerere.perl | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/git-rerere.perl b/git-rerere.perl index b2550bb2ef..61eef575da 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"; } |