chiark / gitweb /
badcommit-fixup: seems to do main thing
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 5 Jan 2017 01:43:22 +0000 (01:43 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 5 Jan 2017 01:43:22 +0000 (01:43 +0000)
badcommit-fixup

index af4b89d2bbb30a39e6d78a93adcd849e9bbf1a72..2eeaefe1402901bbb149ff8162df59fe9efb09ed 100755 (executable)
@@ -30,7 +30,7 @@ sub getobj ($$) {
 sub hashobj ($$) {
     my ($data,$type) = @_;
     my $gwopid = open2 \*GWO, \*GWI,
 sub hashobj ($$) {
     my ($data,$type) = @_;
     my $gwopid = open2 \*GWO, \*GWI,
-       "git hash-object -t $type --stdin"
+       "git hash-object -w -t $type --stdin"
        or die $!;
     print GWI $data or die $!;
     close GWI or die $!;
        or die $!;
     print GWI $data or die $!;
     close GWI or die $!;
@@ -55,14 +55,14 @@ sub rewrite_commit ($) {
     my $msg = $';
     $_ = $`;
     s{^(parent )(\w+)$}{ $1 . rewrite_commit($2) }gme;
     my $msg = $';
     $_ = $`;
     s{^(parent )(\w+)$}{ $1 . rewrite_commit($2) }gme;
-    $count{fix_overwrite} += s{^commiter }{committer }gm;
+    $count{'fix overwrite'} += s{^commiter }{committer }gm;
     if (!m{^author }m && !m{^committer }m) {
        m{^parent (\w+)}m or die "$obj ?";
        my $parent = getobj $1, 'commit';
        $parent =~ m/^(?:.+\n)+(author .*\ncommitter .*\n)/;
        m/\n$/ or die "$obj ?";
        $_ .= $1;
     if (!m{^author }m && !m{^committer }m) {
        m{^parent (\w+)}m or die "$obj ?";
        my $parent = getobj $1, 'commit';
        $parent =~ m/^(?:.+\n)+(author .*\ncommitter .*\n)/;
        m/\n$/ or die "$obj ?";
        $_ .= $1;
-       $count{fix_import}++;
+       $count{'fix import'}++;
     }
     my $newdata = $_.$msg;
     my $newobj;
     }
     my $newdata = $_.$msg;
     my $newobj;
@@ -82,7 +82,7 @@ sub rewrite_tag ($) {
     m/^type (\w+)\n/m or die "$obj ?";
     if ($1 ne 'commit') {
        $count{"oddtags $1"}++;
     m/^type (\w+)\n/m or die "$obj ?";
     if ($1 ne 'commit') {
        $count{"oddtags $1"}++;
-       return;
+       return $obj;
     }
     m/^object (\w+)\n/m or die "$obj ?";
     my $oldref = $1;
     }
     m/^object (\w+)\n/m or die "$obj ?";
     my $oldref = $1;
@@ -111,12 +111,12 @@ foreach my $rline (split /\n/, $refs) {
     if ($type eq 'commit') {
        $rewrite = rewrite_commit($obj);
     } elsif ($type eq 'tag') {
     if ($type eq 'commit') {
        $rewrite = rewrite_commit($obj);
     } elsif ($type eq 'tag') {
-       my $rewrite = rewrite_tag($obj);
+       $rewrite = rewrite_tag($obj);
     } else {
        warn "ref $refname refers to $type\n";
        next;
     }
     } else {
        warn "ref $refname refers to $type\n";
        next;
     }
-    next if $rewrite = $obj;
+    next if $rewrite eq $obj;
     push @updates, [ $refname, $rewrite ];
 }
 
     push @updates, [ $refname, $rewrite ];
 }