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>
Junio C Hamano committed
Dec 8, 2006 at 13:03 UTC
cda2d3c112a03079af9019c7d6617e65ab88ae7e
2 files changed
+57
-24
Documentation/git-rerere.txt
+32
-24
@@ -26,6 +26,38 @@ results and applying the previously recorded hand resolution.
26
You need to create `$GIT_DIR/rr-cache` directory to enable this
27
command.
28
29
+
30
+COMMANDS
31
+--------
32
+
33
+Normally, git-rerere is run without arguments or user-intervention.
34
+However, it has several commands that allow it to interact with
35
+its working state.
36
+
37
+'clear'::
38
+
39
+This resets the metadata used by rerere if a merge resolution is to be
40
+is aborted. Calling gitlink:git-am[1] --skip or gitlink:git-rebase[1]
41
+[--skip|--abort] will automatcally invoke this command.
42
+
43
+'diff'::
44
+
45
+This displays diffs for the current state of the resolution. It is
46
+useful for tracking what has changed while the user is resolving
47
+conflicts. Additional arguments are passed directly to the system
48
+diff(1) command installed in PATH.
49
+
50
+'status'::
51
+
52
+Like diff, but this only prints the filenames that will be tracked
53
+for resolutions.
54
+
55
+'gc'::
56
+
57
+This command is used to prune records of conflicted merge that
58
+occurred long time ago.
59
+
60
+
61
DISCUSSION
62
----------
63
@@ -166,30 +198,6 @@ would conflict the same way the test merge you resolved earlier.
198
`git-rerere` is run by `git rebase` to help you resolve this
199
conflict.
200
169
-COMMANDS
170
---------
171
-
172
-Normally, git-rerere is run without arguments or user-intervention.
173
-However, it has several commands that allow it to interact with
174
-its working state.
175
-
176
-'clear'::
177
-
178
-This resets the metadata used by rerere if a merge resolution is to be
179
-is aborted. Calling gitlink:git-am[1] --skip or gitlink:git-rebase[1]
180
-[--skip|--abort] will automatcally invoke this command.
181
-
182
-'diff'::
183
-
184
-This displays diffs for the current state of the resolution. It is
185
-useful for tracking what has changed while the user is resolving
186
-conflicts. Additional arguments are passed directly to the system
187
-diff(1) command installed in PATH.
188
-
189
-'status'::
190
-
191
-Like diff, but this only prints the filenames that will be tracked
192
-for resolutions.
201
202
Author
203
------
git-rerere.perl
+25
@@ -169,6 +169,28 @@ sub merge {
169
return 0;
170
}
171
172
+sub garbage_collect_rerere {
173
+ # We should allow specifying these from the command line and
174
+ # that is why the caller gives @ARGV to us, but I am lazy.
175
+
176
+ my $cutoff_noresolve = 15; # two weeks
177
+ my $cutoff_resolve = 60; # two months
178
+ my @to_remove;
179
+ while (<$rr_dir/*/preimage>) {
180
+ my ($dir) = /^(.*)\/preimage$/;
181
+ my $cutoff = ((-f "$dir/postimage")
182
+ ? $cutoff_resolve
183
+ : $cutoff_noresolve);
184
+ my $age = -M "$_";
185
+ if ($cutoff <= $age) {
186
+ push @to_remove, $dir;
187
+ }
188
+ }
189
+ if (@to_remove) {
190
+ rmtree(\@to_remove);
191
+ }
192
+}
193
+
194
-d "$rr_dir" || exit(0);
195
196
read_rr();
@@ -198,6 +220,9 @@ if (@ARGV) {
220
"$rr_dir/$name/preimage", $path);
221
}
222
}
223
+ elsif ($arg eq 'gc') {
224
+ garbage_collect_rerere(@ARGV);
225
+ }
226
else {
227
die "$0 unknown command: $arg\n";
228
}