X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=dgit.git;a=blobdiff_plain;f=dgit;h=97bd283170e833209d36f2e0bbd3546cf0bea17a;hp=d59d2f5f17d7652131628ee502f0c667e100ed8b;hb=6ea481cc3ed14084a6917b16443d228dc124bbe5;hpb=399e378d0e45338911e0d55a3d34988172c609d9 diff --git a/dgit b/dgit index d59d2f5f..97bd2831 100755 --- a/dgit +++ b/dgit @@ -1209,10 +1209,12 @@ our ($dsc_hash,$lastpush_hash); our $ud = '.git/dgit/unpack'; -sub prep_ud () { - rmtree($ud); +sub prep_ud (;$) { + my ($d) = @_; + $d //= $ud; + rmtree($d); mkpath '.git/dgit'; - mkdir $ud or die $!; + mkdir $d or die $!; } sub mktree_in_ud_here () { @@ -2530,8 +2532,8 @@ sub quiltify_tree_sentinelfiles ($) { return $r; } -sub quiltify ($$) { - my ($clogp,$target) = @_; +sub quiltify ($$$) { + my ($clogp,$target,$origtree) = @_; # Quilt patchification algorithm # @@ -2558,8 +2560,6 @@ sub quiltify ($$) { # should be contained within debian/patches. changedir '../fake'; - remove_stray_gits(); - mktree_in_ud_here(); rmtree '.pc'; runcmd @git, qw(add -Af .); my $oldtiptree=git_write_tree(); @@ -2882,6 +2882,18 @@ sub quilt_fixup_multipatch ($$$) { # 5. If we had a .pc in-tree, delete it, and git-commit # 6. Back in the main tree, fast forward to the new HEAD + # Another situation we may have to cope with is gbp-style + # patches-unapplied trees. We want to detect these, so we know + # to escape into quilt_fixup_gbp. + # + # A gbp-style tree is one which is not a clean patches-applied + # tree, but _is_ a clean patches-unapplied tree. + # + # To help detect this, when we are extracting the fake dsc, we + # first extract it with --skip-patches, and then apply the patches + # afterwards with dpkg-source --before-build. That lets us save a + # tree object corresponding to .origs. + my $fakeversion="$upstreamversion-~~DGITFAKE"; my $fakedsc=new IO::File 'fake.dsc', '>' or die $!; @@ -2907,7 +2919,8 @@ END quilt_fixup_linkorigs($upstreamversion, $dscaddfile); - my @files=qw(debian/source/format debian/rules); + my @files=qw(debian/source/format debian/rules + debian/control debian/changelog); foreach my $maybe (qw(debian/patches debian/source/options)) { next unless stat_exists "../../../$maybe"; push @files, $maybe; @@ -2919,11 +2932,31 @@ END $dscaddfile->($debtar); close $fakedsc or die $!; - runcmd qw(sh -ec), 'exec dpkg-source --no-check -x fake.dsc >/dev/null'; + runcmd qw(sh -ec), + 'exec dpkg-source --no-check --skip-patches -x fake.dsc >/dev/null'; my $fakexdir= $package.'-'.(stripepoch $upstreamversion); rename $fakexdir, "fake" or die "$fakexdir $!"; + changedir 'fake'; + + remove_stray_gits(); + mktree_in_ud_here(); + + rmtree '.pc'; + + runcmd @git, qw(add -Af .); + my $origtree=git_write_tree(); + + printdebug "fake orig tree object $origtree\n"; + + ensuredir '.pc'; + + runcmd qw(sh -ec), + 'exec dpkg-source --before-build . >/dev/null'; + + changedir '..'; + quilt_fixup_mkwork($headref); my $mustdeletepc=0; @@ -2935,7 +2968,7 @@ END rename '../fake/.pc','.pc' or die $!; } - quiltify($clogp,$headref); + quiltify($clogp,$headref,$origtree); if (!open P, '>>', ".pc/applied-patches") { $!==&ENOENT or die $!;