summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Jackson <ijackson@chiark.greenend.org.uk>2017-01-05 19:10:37 +0000
committerIan Jackson <ijackson@chiark.greenend.org.uk>2017-01-05 19:10:37 +0000
commit15efa428cc98a11fae7bdf1a7cbb449b82bb3359 (patch)
tree1b63808080aec15cdb19c8dabdb1a07da4ca71e1
parent999d80d3850ec7f42ec877e59c9d192fa7a14147 (diff)
badcommit-fixup: break out $bare
-rwxr-xr-xbadcommit-fixup14
1 files changed, 9 insertions, 5 deletions
diff --git a/badcommit-fixup b/badcommit-fixup
index 42dd67b..732974c 100755
--- a/badcommit-fixup
+++ b/badcommit-fixup
@@ -31,12 +31,13 @@ our %count;
no warnings qw(recursion);
sub runcmd {
- system @_ and die "$! $?";
+ system @_ and die "@_ $! $?";
}
$!=0; $?=0;
my $bare = `git rev-parse --is-bare-repository`;
die "$? $!" if $?;
+chomp $bare or die;
sub getobj ($$) {
my ($obj, $type) = @_;
@@ -79,7 +80,7 @@ sub rewrite_commit ($) {
my $olddata = getobj $obj, 'commit';
$olddata =~ m/(?<=\n)(?=\n)/ or die "$obj ?";
my $msg = $';
- $_ = $`;
+ local $_ = $`;
s{^(parent )(\w+)$}{ $1 . rewrite_commit($2) }gme;
$count{'fix overwrite'} += s{^commiter }{committer }gm;
if (!m{^author }m && !m{^committer }m) {
@@ -113,8 +114,8 @@ sub rewrite_commit_adddummy ($$$) {
chdir $td or die $!;
runcmd qw(git init -q);
runcmd qw(git config gc.auto 0);
- rmdir ".git/objects";
- symlink "../objects", ".git/objects" or die $!;
+ runcmd qw(rm -rf .git/objects);
+ symlink "../../objects", ".git/objects" or die $!;
runcmd qw(git checkout -q), $old;
open C, "debian/changelog" or die $!;
@@ -199,7 +200,10 @@ foreach my $rline (split /\n/, $refs) {
my $rewrite;
if ($type eq 'commit') {
$rewrite = rewrite_commit($obj);
- if ($refname =~ m{^refs/dgit/^[/]+$}) {
+print STDERR "RW? $refname $obj $rewrite\n";
+ if ($refname =~ m{^refs/dgit/[^/]+$} &&
+ $rewrite ne $obj) {
+print STDERR "RW $refname\n";
$rewrite = rewrite_commit_adddummy $refname, $obj, $rewrite;
}
} elsif ($type eq 'tag') {