From d4040f3460d88d6e2125566139644d2652e2f05f Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Thu, 5 Jan 2017 18:31:31 +0000 Subject: [PATCH] badcommit-fixup: wip dummy commits --- badcommit-fixup | 74 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 72 insertions(+), 2 deletions(-) diff --git a/badcommit-fixup b/badcommit-fixup index 44c0702..dd404bb 100755 --- a/badcommit-fixup +++ b/badcommit-fixup @@ -1,7 +1,7 @@ #!/usr/bin/perl -w # usage: -# .../badcommit-fixup [-- --test +# .../badcommit-fixup --test # .../badcommit-fixup --real use strict; @@ -142,12 +142,82 @@ $!=0; $?=0; my $bare = `git rev-parse --is-bare-repository`; die "$? $!" if $?; +our $worktree; + +sub runcmd { + system @_ and die "$! $?"; +} + +for my $up (@updates) { + my ($ref, $veryold, $old) = @$up; + next unless $ref =~ m{^refs/dgit/^[/]+$}; + + die "$bare ?" unless $bare eq 'true'; + + my $td = 'dgit-broken-fixup.tmp'; + runcmd qw(rm -rf), $td; + mkdir $td, 0700 or die "$td $!"; + 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(git checkout -q), $old; + + open C, "debian/changelog" or die $!; + undef $/; + my $clog = ; + C->error and die $!; + close C or die $!; + defined $clog or die $!; + + $!=0; $?=0; + my $v = `dpkg-parsechangelog`; + die "$ref $veryold $old $? $!" if $?; + $v =~ m/^Source: (\S+)$/m or die "$ref $veryold $old ?"; + my $pkg = $1; + $v =~ m/^Version: (\S+)$/m or die "$ref $veryold $old ?"; + my $vsn = $1; + $vsn .= "+~dgitfix"; + + open C, ">", "debian/changelog" or die $!; + print C < Thu, 05 Jan 2017 17:58:21 +0000 + +END + print C $clog or die $!; + close C or die $!; + + runcmd qw(git commit -q), + '--author=Ian Jackson ', + qw(-m), 'Dummy changelog entry to work around #849041 fallout', + qw(debian/changelog); + + $!=0; $?=0; + my $new = `git rev-parse HEAD`; + die "$? $!" if $?; + + chdir '..' or die $!; + runcmd qw(rm -rf), $td; + + $count{dummyadded}++; + + $up->[2] = $new; +} + open U, "|git update-ref -m 'dgit bad commit fixup' --stdin" or die $!; if ($real) { if ($bare eq 'false') { print "detaching your HEAD\n" or die $!; - system 'git checkout --detach' and die "$! $?"; + runcmd 'git checkout --detach'; } } -- 2.30.2