aboutsummaryrefslogtreecommitdiff
path: root/git-rerere.perl
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2006-12-13 11:08:35 -0800
committerJunio C Hamano <junkio@cox.net>2006-12-13 11:08:35 -0800
commitd0085ade9598942077f12f22b16978411d15188a (patch)
tree27cc41e9eae9f3909aad1f940768d17cccee7abd /git-rerere.perl
parent78ba00407cf69c9f57f17e07d156336ce47c2b03 (diff)
parentf131dd492f098f9f565df93df13e35c734284590 (diff)
downloadgit-d0085ade9598942077f12f22b16978411d15188a.tar.gz
git-d0085ade9598942077f12f22b16978411d15188a.tar.xz
Merge branch 'ew/rerere'
* ew/rerere: rerere: record (or avoid misrecording) resolved, skipped or aborted rebase/am git-rerere: add 'gc' command. rerere: add clear, diff, and status commands
Diffstat (limited to 'git-rerere.perl')
-rwxr-xr-xgit-rerere.perl57
1 files changed, 57 insertions, 0 deletions
diff --git a/git-rerere.perl b/git-rerere.perl
index 2e8dbbd4e..fdd685489 100755
--- a/git-rerere.perl
+++ b/git-rerere.perl
@@ -169,9 +169,66 @@ 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();
+
+if (@ARGV) {
+ my $arg = shift @ARGV;
+ if ($arg eq 'clear') {
+ for my $path (keys %merge_rr) {
+ my $name = $merge_rr{$path};
+ if (-d "$rr_dir/$name" &&
+ ! -f "$rr_dir/$name/postimage") {
+ rmtree(["$rr_dir/$name"]);
+ }
+ }
+ unlink $merge_rr;
+ }
+ elsif ($arg eq 'status') {
+ for my $path (keys %merge_rr) {
+ print $path, "\n";
+ }
+ }
+ elsif ($arg eq 'diff') {
+ for my $path (keys %merge_rr) {
+ my $name = $merge_rr{$path};
+ system('diff', ((@ARGV == 0) ? ('-u') : @ARGV),
+ '-L', "a/$path", '-L', "b/$path",
+ "$rr_dir/$name/preimage", $path);
+ }
+ }
+ elsif ($arg eq 'gc') {
+ garbage_collect_rerere(@ARGV);
+ }
+ else {
+ die "$0 unknown command: $arg\n";
+ }
+ exit 0;
+}
+
my %conflict = map { $_ => 1 } find_conflict();
# MERGE_RR records paths with conflicts immediately after merge