From 120cd303970c29804b9c07f94e1944e89544eadf Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 29 Jun 2019 12:53:56 +0100 Subject: [PATCH] dgit: baredebian: New quilt mode This is the bulk of the implementation including all essential changes. Signed-off-by: Ian Jackson --- dgit | 54 +++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 43 insertions(+), 11 deletions(-) diff --git a/dgit b/dgit index fb64dc2d..02cf97d8 100755 --- a/dgit +++ b/dgit @@ -80,7 +80,7 @@ our $rmchanges; our $overwrite_version; # undef: not specified; '': check changelog our $quilt_mode; our $quilt_upstream_commitish; -our $quilt_modes_re = 'linear|smash|auto|nofix|nocheck|gbp|dpm|unapplied'; +our $quilt_modes_re = 'linear|smash|auto|nofix|nocheck|gbp|dpm|unapplied|baredebian'; our $splitview_mode; our $splitview_modes_re = qr{auto|always|never}; our $dodep14tag; @@ -295,7 +295,7 @@ sub deliberately_not_fast_forward () { } sub quiltmode_splitting () { - $quilt_mode =~ m/gbp|dpm|unapplied/; + $quilt_mode =~ m/gbp|dpm|unapplied|baredebian/; } sub do_split_brain () { !!($do_split_brain // confess) } @@ -5359,7 +5359,7 @@ sub quiltify_splitting ($$$$$$$) { my ($clogp, $unapplied, $headref, $oldtiptree, $diffbits, $editedignores, $cachekey) = @_; my $gitignore_special = 1; - if ($quilt_mode !~ m/gbp|dpm/) { + if ($quilt_mode !~ m/gbp|dpm|baredebian/) { # treat .gitignore just like any other upstream file $diffbits = { %$diffbits }; $_ = !!$_ foreach values %$diffbits; @@ -5384,14 +5384,14 @@ sub quiltify_splitting ($$$$$$$) { $cmd; }; - if ($quilt_mode =~ m/gbp|unapplied/ && + if ($quilt_mode =~ m/gbp|unapplied|baredebian/ && ($diffbits->{O2H} & 01)) { my $msg = f_ "--quilt=%s specified, implying patches-unapplied git tree\n". " but git tree differs from orig in upstream files.", $quilt_mode; $msg .= $fulldiffhint->($unapplied, 'HEAD'); - if (!stat_exists "debian/patches") { + if (!stat_exists "debian/patches" and $quilt_mode !~ m/baredebian/) { $msg .= __ "\n ... debian/patches is missing; perhaps this is a patch queue branch?"; } @@ -5404,7 +5404,22 @@ sub quiltify_splitting ($$$$$$$) { but git tree differs from result of applying debian/patches to upstream END } - if ($quilt_mode =~ m/gbp|unapplied/ && + if ($quilt_mode =~ m/baredebian/) { + # We need to construct a merge which has upstream files from + # upstream and debian/ files from HEAD. + + read_tree_upstream $quilt_upstream_commitish, 1, $headref; + my $upsversion = upstreamversion getfield $clogp, 'Version'; + my $merge = make_commit + [ $headref, $quilt_upstream_commitish ], + [ +(f_ <{O2A} & 01)) { # some patches progress __ "dgit view: creating patches-applied version using gbp pq"; runcmd shell_cmd 'exec >/dev/null', gbp_pq, qw(import); @@ -6169,9 +6184,17 @@ END # We calculate some guesswork now about what kind of tree this might # be. This is mostly for error reporting. + my $tentries = cmdoutput @git, qw(ls-tree --name-only -z), $headref; + my $onlydebian = $tentries eq "debian\0"; + my $uheadref = $headref; my $uhead_whatshort = 'HEAD'; + if ($quilt_mode =~ m/baredebian/) { + $uheadref = $quilt_upstream_commitish; + $uhead_whatshort = __ 'upstream'; + } + my %editedignores; my @unrepres; my $diffbits = { @@ -6201,7 +6224,10 @@ END $us, $dl[0], $dl[1], $dl[3], $dl[4], $us, $uhead_whatshort, $dl[2], $uhead_whatshort, $dl[5]; - if (@unrepres) { + if (@unrepres && $quilt_mode !~ m/baredebian/) { + # With baredebian, even if the upstream commitish has this + # problem, we don't want to print this message, as nothing + # is going to try to make a patch out of it anyway. print STDERR f_ "dgit: cannot represent change: %s: %s\n", $_->[1], $_->[0] foreach @unrepres; @@ -6211,7 +6237,11 @@ END } my @failsuggestion; - if (!($diffbits->{O2H} & $diffbits->{O2A})) { + if ($onlydebian) { + push @failsuggestion, [ 'onlydebian', __ + "This has only a debian/ directory; you probably want --quilt=bare debian." ] + unless $quilt_mode =~ m/baredebian/; + } elsif (!($diffbits->{O2H} & $diffbits->{O2A})) { push @failsuggestion, [ 'unapplied', __ "This might be a patches-unapplied branch." ]; } elsif (!($diffbits->{H2A} & $diffbits->{O2A})) { @@ -6226,7 +6256,9 @@ END if stat_exists '.gitattributes'; push @failsuggestion, [ 'origs', __ - "Maybe orig tarball(s) are not identical to git representation?" ]; + "Maybe orig tarball(s) are not identical to git representation?" ] + unless $onlydebian && $quilt_mode !~ m/baredebian/; + # ^ in that case, we didn't really look properly if (quiltmode_splitting()) { quiltify_splitting($clogp, $unapplied, $headref, $oldtiptree, @@ -6272,7 +6304,7 @@ sub quilt_fixup_editor () { } sub maybe_apply_patches_dirtily () { - return unless $quilt_mode =~ m/gbp|unapplied/; + return unless $quilt_mode =~ m/gbp|unapplied|baredebian/; print STDERR __ <