summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Jackson <ijackson@chiark.greenend.org.uk>2023-02-04 12:09:54 +0000
committerIan Jackson <ijackson@chiark.greenend.org.uk>2023-02-04 14:26:04 +0000
commit097e75b676bf886e2cf1bf5fbd0459382edd43b2 (patch)
tree9b8cda8b5216e9363177801b476c2ec1ada4767c
parent620f1c31eda3d1245813900117c6876aec05d308 (diff)
dgit: dsc import: Launder the series file before feeding it to gbp
Closes: #1030093 Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
-rwxr-xr-xdgit42
1 files changed, 42 insertions, 0 deletions
diff --git a/dgit b/dgit
index 98e88c2..8da13d3 100755
--- a/dgit
+++ b/dgit
@@ -2746,6 +2746,39 @@ END
local $ENV{DGIT_ABSURD_DEBUG} = $debuglevel if $use_absurd;
local $ENV{PATH} = $path if $use_absurd;
+ if ($use_absurd) {
+ # We filter the series file, to contain only things
+ # that are actually requests to apply a patch.
+ #
+ # This is needed because sometimes a series file can
+ # contain strange things that gbp pq cannot cope with.
+ # Eg, form feeds. See #1030093.
+ rename "debian/patches/series", "../series.orig"
+ or confess "$!";
+ open OS, "../series.orig" or confess $!;
+ open NS, ">debian/patches/series" or confess $!;
+ while (<OS>) {
+ s/\#.*//;
+ s/^\s+//;
+ s/\s+$//;
+ next unless m/\S/;
+ print NS "$_\n" or confess $!;
+ }
+ confess $! if OS->error;
+ close NS or confess $!;
+ runcmd @git, qw(add debian/patches/series);
+ # This commit is spurious, but we must commit for gbp
+ # pq to work. We filter it out of the branch later.
+ runcmd @git, qw(commit --quiet --allow-empty -m), <<END;
+INTERNAL commit to launder series file
+
+This commit should not escape into a public branch!
+If you see it, this is due to a bug in dgit.
+
+[dgit ($our_version) INTERNAL-quilt-fixup-series]
+END
+ }
+
my @showcmd = (gbp_pq, qw(import));
my @realcmd = shell_cmd
'exec >/dev/null 2>../../gbp-pq-output', @showcmd;
@@ -2758,6 +2791,15 @@ END
}
});
+ if ($use_absurd) {
+ # Perhaps we should be using git-filter-branch,
+ # but that's really considerably more awkward.
+ # TODO: even --quiet still leave some stderr output ;-/
+ runcmd
+ @git, qw(rebase --keep-empty --allow-empty-message
+ --onto unpa~1 unpa);
+ }
+
my $gapplied = git_rev_parse('HEAD');
my $gappliedtree = cmdoutput @git, qw(rev-parse HEAD:);
$gappliedtree eq $dappliedtree or