}
}
-sub quiltify_trees_differ ($$) {
- my ($x,$y) = @_;
+sub quiltify_trees_differ ($$;$) {
+ my ($x,$y,$ignoregitignore) = @_;
# returns 1 iff the two tree objects differ other than in debian/
local $/=undef;
my @cmd = (@git, qw(diff-tree --name-only -z), $x, $y);
my $diffs= cmdoutput @cmd;
foreach my $f (split /\0/, $diffs) {
next if $f eq 'debian';
+ next if $f eq '.gitignore' && $ignoregitignore;
return 1;
}
return 0;
return $r;
}
-sub quiltify ($$$) {
- my ($clogp,$target,$origtree) = @_;
+sub quilt_could_gbp ($$$) {
+ my ($userhead,$unapplied,$applied) = @_;
+ return
+ !quiltify_trees_differ($userhead,$unapplied,1) &&
+ quiltify_trees_differ($userhead,$applied,1);
+}
+
+sub quiltify ($$$$) {
+ my ($clogp,$target,$unapplied,$oldtiptree) = @_;
# Quilt patchification algorithm
#
# After traversing PT, we git commit the changes which
# should be contained within debian/patches.
- changedir '../fake';
- rmtree '.pc';
- runcmd @git, qw(add -Af .);
- my $oldtiptree=git_write_tree();
- changedir '../work';
-
# The search for the path S..T is breadth-first. We maintain a
# todo list containing search nodes. A search node identifies a
# commit, and looks something like this:
foreach my $notp (@nots) {
print STDERR "$us: ", $reportnot->($notp), "\n";
}
+ if (quilt_could_gbp($target,$unapplied,$oldtiptree)) {
+ print STDERR <<END;
+$us: Tree looks like a patches-unapplied git branch.
+$us: Maybe you forgot --quilt=gbp (aka --quilt=apply) ?
+END
+ }
fail "quilt fixup naive history linearisation failed.\n".
"Use dpkg-source --commit by hand; or, --quilt=smash for one ugly patch";
} elsif ($quilt_mode eq 'smash') {
# 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.
+ # patches-unapplied trees.
+ #
+ # We would want to detect these, so we know to escape into
+ # quilt_fixup_gbp. However, this is in general not possible.
+ # Consider a package with a one patch which the dgit user reverts
+ # (with git-revert or the moral equivalent).
+ #
+ # That is indistinguishable in contents from a patches-unapplied
+ # tree. And looking at the history to distinguish them is not
+ # useful because the user might have made a confusing-looking git
+ # history structure (which ought to produce an error if dgit can't
+ # cope, not a silent reintroduction of an unwanted patch).
#
- # A gbp-style tree is one which is not a clean patches-applied
- # tree, but _is_ a clean patches-unapplied tree.
+ # So gbp users will have to pass an option. But we can usually
+ # detect their failure to do so: if the tree is not a clean
+ # patches-applied tree, quilt linearisation fails, but the tree
+ # _is_ a clean patches-unapplied tree, we can suggest that maybe
+ # they want --quilt=unapplied.
#
# To help detect this, when we are extracting the fake dsc, we
# first extract it with --skip-patches, and then apply the patches
rmtree '.pc';
runcmd @git, qw(add -Af .);
- my $origtree=git_write_tree();
-
- printdebug "fake orig tree object $origtree\n";
+ my $unapplied=git_write_tree();
+ printdebug "fake orig tree object $unapplied\n";
ensuredir '.pc';
rename '../fake/.pc','.pc' or die $!;
}
- quiltify($clogp,$headref,$origtree);
+ changedir '../fake';
+ rmtree '.pc';
+ runcmd @git, qw(add -Af .);
+ my $oldtiptree=git_write_tree();
+ changedir '../work';
+
+ quiltify($clogp,$headref,$unapplied,$oldtiptree);
if (!open P, '>>', ".pc/applied-patches") {
$!==&ENOENT or die $!;