Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

git-tag-lost-commits: a small utility to find "lost" commits

  • Loading branch information...
commit 3dd6669e7ea7a56dd0ffaa0c5809ddb5667ce30e 0 parents
@book authored
Showing with 22 additions and 0 deletions.
  1. +22 −0 git-tag-lost-commits
22 git-tag-lost-commits
@@ -0,0 +1,22 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use Git;
+
+my $repo = Git->repository;
+my ( $fh, $c )
+ = $repo->command_output_pipe(
+ qw( fsck --unreachable --full --no-reflogs ));
+
+my $n = 0;
+while (<$fh>) {
+ chomp;
+ next if !/ commit /;
+ my ($sha1) = /(\w{40})/;
+ my $tag = sprintf( 'lost+found-%04d', $n );
+ $repo->command( 'tag', $tag, $sha1 );
+ print "Tagging $sha1 as $tag\n";
+ $n++;
+}
+$repo->command_close_pipe( $fh, $c );
+
Please sign in to comment.
Something went wrong with that request. Please try again.