X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;ds=sidebyside;f=badcommit-fixup;fp=badcommit-fixup;h=732974c10e28e5bad7d90fce0b12f8443b29080a;hb=15efa428cc98a11fae7bdf1a7cbb449b82bb3359;hp=42dd67b005fef11e8cb0335ba5c5c056362bebad;hpb=999d80d3850ec7f42ec877e59c9d192fa7a14147;p=dgit.git diff --git a/badcommit-fixup b/badcommit-fixup index 42dd67b0..732974c1 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') {