aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Documentation/git-rerere.txt56
-rwxr-xr-xgit-rerere.perl25
2 files changed, 57 insertions, 24 deletions
diff --git a/Documentation/git-rerere.txt b/Documentation/git-rerere.txt
index 22494b2b2..116dca4c0 100644
--- a/Documentation/git-rerere.txt
+++ b/Documentation/git-rerere.txt
@@ -26,6 +26,38 @@ results and applying the previously recorded hand resolution.
You need to create `$GIT_DIR/rr-cache` directory to enable this
command.
+
+COMMANDS
+--------
+
+Normally, git-rerere is run without arguments or user-intervention.
+However, it has several commands that allow it to interact with
+its working state.
+
+'clear'::
+
+This resets the metadata used by rerere if a merge resolution is to be
+is aborted. Calling gitlink:git-am[1] --skip or gitlink:git-rebase[1]
+[--skip|--abort] will automatcally invoke this command.
+
+'diff'::
+
+This displays diffs for the current state of the resolution. It is
+useful for tracking what has changed while the user is resolving
+conflicts. Additional arguments are passed directly to the system
+diff(1) command installed in PATH.
+
+'status'::
+
+Like diff, but this only prints the filenames that will be tracked
+for resolutions.
+
+'gc'::
+
+This command is used to prune records of conflicted merge that
+occurred long time ago.
+
+
DISCUSSION
----------
@@ -166,30 +198,6 @@ would conflict the same way the test merge you resolved earlier.
`git-rerere` is run by `git rebase` to help you resolve this
conflict.
-COMMANDS
---------
-
-Normally, git-rerere is run without arguments or user-intervention.
-However, it has several commands that allow it to interact with
-its working state.
-
-'clear'::
-
-This resets the metadata used by rerere if a merge resolution is to be
-is aborted. Calling gitlink:git-am[1] --skip or gitlink:git-rebase[1]
-[--skip|--abort] will automatcally invoke this command.
-
-'diff'::
-
-This displays diffs for the current state of the resolution. It is
-useful for tracking what has changed while the user is resolving
-conflicts. Additional arguments are passed directly to the system
-diff(1) command installed in PATH.
-
-'status'::
-
-Like diff, but this only prints the filenames that will be tracked
-for resolutions.
Author
------
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";
}