summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Debian/Dgit.pm30
-rw-r--r--debian/changelog59
-rw-r--r--debian/tests/control2
-rwxr-xr-xdgit112
-rw-r--r--dgit-maint-debrebase.7.pod7
-rw-r--r--dgit.126
-rwxr-xr-xgit-debrebase370
-rw-r--r--git-debrebase.1.pod89
-rw-r--r--git-debrebase.5.pod42
-rw-r--r--tests/Makefile2
-rw-r--r--tests/lib-gdr3
-rwxr-xr-xtests/setup/gdr-convert-gbp8
-rwxr-xr-xtests/tests/gdr-diverge-nmu1
-rwxr-xr-xtests/tests/gdr-edits1
-rwxr-xr-xtests/tests/gdr-import-dgit1
-rwxr-xr-xtests/tests/gdr-import-dgitview45
-rwxr-xr-xtests/tests/gdr-makepatches71
-rwxr-xr-xtests/tests/gdr-newupstream1
-rwxr-xr-xtests/tests/gdr-subcommands12
-rwxr-xr-xtests/tests/gdr-unprocessable61
-rwxr-xr-xtests/tests/gdr-viagit15
21 files changed, 788 insertions, 100 deletions
diff --git a/Debian/Dgit.pm b/Debian/Dgit.pm
index 0e2464d..1cd765d 100644
--- a/Debian/Dgit.pm
+++ b/Debian/Dgit.pm
@@ -43,6 +43,8 @@ BEGIN {
dep14_version_mangle
debiantags debiantag_old debiantag_new
debiantag_maintview
+ upstreamversion
+ stripepoch source_file_leafname is_orig_file_of_p_v
server_branch server_ref
stat_exists link_ltarget
hashfile
@@ -57,6 +59,7 @@ BEGIN {
git_reflog_action_msg git_update_ref_cmd
$package_re $component_re $deliberately_re
$distro_re $versiontag_re $series_filename_re
+ $orig_f_comp_re $orig_f_sig_re $orig_f_tail_re
$extra_orig_namepart_re
$git_null_obj
$branchprefix
@@ -91,6 +94,9 @@ our $versiontag_re = qr{[-+.\%_0-9a-zA-Z/]+};
our $branchprefix = 'dgit';
our $series_filename_re = qr{(?:^|\.)series(?!\n)$}s;
our $extra_orig_namepart_re = qr{[-0-9a-z]+};
+our $orig_f_comp_re = qr{orig(?:-$extra_orig_namepart_re)?};
+our $orig_f_sig_re = '\\.(?:asc|gpg|pgp)';
+our $orig_f_tail_re = "$orig_f_comp_re\\.tar(?:\\.\\w+)?(?:$orig_f_sig_re)?";
our $git_null_obj = '0' x 40;
our $ffq_refprefix = 'ffq-prev';
our $gdrlast_refprefix = 'debrebase-last';
@@ -220,6 +226,30 @@ sub debiantags ($$) {
map { $_->($version, $distro) } (\&debiantag_new, \&debiantag_old);
}
+sub stripepoch ($) {
+ my ($vsn) = @_;
+ $vsn =~ s/^\d+\://;
+ return $vsn;
+}
+
+sub upstreamversion ($) {
+ my ($vsn) = @_;
+ $vsn =~ s/-[^-]+$//;
+ return $vsn;
+}
+
+sub source_file_leafname ($$$) {
+ my ($package,$vsn,$sfx) = @_;
+ return "${package}_".(stripepoch $vsn).$sfx
+}
+
+sub is_orig_file_of_p_v ($$$) {
+ my ($f, $package, $upstreamvsn) = @_;
+ my $base = source_file_leafname $package, $upstreamvsn, '';
+ return 0 unless $f =~ m/^\Q$base\E\.$orig_f_tail_re$/;
+ return 1;
+}
+
sub server_branch ($) { return "$branchprefix/$_[0]"; }
sub server_ref ($) { return "refs/".server_branch($_[0]); }
diff --git a/debian/changelog b/debian/changelog
index 6b485f9..2e04c19 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,62 @@
+dgit (6.6) unstable; urgency=medium
+
+ * test suite: Fix gdr's calls to dgit when run formally in
+ autopkgtest. (Affects gdr-import-dgitview.)
+
+ -- Ian Jackson <ijackson@chiark.greenend.org.uk> Sun, 05 Aug 2018 10:42:01 +0100
+
+dgit (6.5) unstable; urgency=medium
+
+ git-debrebase new features:
+ * git-debrebase: Provide new convert-from-dgit-view operation.
+ The output is, unavoidably, not very pretty. Closes:#905322.
+ * git-debrebase: New subcommand `scrap'. Closes:#905063.
+
+ git-debrebase error handling improvements:
+ * git-debrebase: Properly reject bare dgit dsc imports
+ * git-debrebase: Improve some error message formatting.
+ * git-debrebase: Check for git-rebase in progress and abort most operations.
+
+ dgit improvements:
+ * dgit: Improve error message for unknown suite, to suggest -d.
+ * dgit: Rename --dgit-view-save to --save-dgit-view, leaving an alias.
+ * dgit: Provide print-unapplied-treeish subcommand.
+
+ Test suite changes:
+ * test suite: Add t-tstunt-parsechangelog to many gdr tests.
+ * test suite: editing a test script overrides DGIT_TESTS_PROGRESSIVE.
+ * test suite: gdr-import-dgitview: New test for dgit dsc imports.
+
+ -- Ian Jackson <ijackson@chiark.greenend.org.uk> Sat, 04 Aug 2018 17:53:57 +0100
+
+dgit (6.4) unstable; urgency=medium
+
+ * git-debrebase(1): Fix typo "unappled". Closes:#905064.
+
+ -- Ian Jackson <ijackson@chiark.greenend.org.uk> Thu, 02 Aug 2018 08:24:32 +0100
+
+dgit (6.3) unstable; urgency=medium
+
+ * git-debrebase: breakwater: Fix error message for unprocessable
+ commits. Closes:#905003.
+ * git-debrebase: new-upstream: Fix error message for new version
+ with bad syntax.
+ * git-debrebase test suite: Test messages about unprocessable commits.
+ * git-debrebase: new-upstream: Fix handling of epochs.
+ * git-debrebase: convert-from-gbp: Use same algorithm for finding
+ upstream commitish as new-upstream. Closes:#905062.
+ * git-debrebase: Improve error messages for bad options.
+ * git-debrebase: Improve error message for convert-from-gbp
+ upstream discrepancy. Closes:#905078.
+ * git-debrebase(5): Add ILLEGAL OPERATIONS section. (Re#905004.)
+ * git-debrebase(1): Warn against plain git rebase. (Re#905004.)
+ * dgit-maint-debrebase(7): Warn more against plain git rebase.
+ Closes:#905004.
+ * git-debrebase: Implement --help, providing a summary.
+ Closes:#904990.
+
+ -- Ian Jackson <ian@zealot.relativity.greenend.org.uk> Thu, 02 Aug 2018 03:45:40 +0100
+
dgit (6.2~bpo9+1) stretch-backports; urgency=medium
* Rebuild for stretch-backports.
diff --git a/debian/tests/control b/debian/tests/control
index 8480655..e3274f2 100644
--- a/debian/tests/control
+++ b/debian/tests/control
@@ -16,7 +16,7 @@ Tests-Directory: tests/tests
Depends: dgit, dgit-infrastructure, devscripts, debhelper (>=8), fakeroot, build-essential, chiark-utils-bin, bc
Restrictions: x-dgit-intree-only x-dgit-git-only
-Tests: gdr-diverge-nmu gdr-diverge-nmu-dgit gdr-edits gdr-import-dgit gdr-makepatches7 gdr-subcommands
+Tests: gdr-diverge-nmu gdr-diverge-nmu-dgit gdr-edits gdr-import-dgit gdr-import-dgitview gdr-makepatches7 gdr-subcommands gdr-unprocessable
Tests-Directory: tests/tests
Depends: dgit, dgit-infrastructure, devscripts, debhelper (>=8), fakeroot, build-essential, chiark-utils-bin, bc, git-debrebase, git-buildpackage, faketime
diff --git a/dgit b/dgit
index 4e43d21..dbb23f3 100755
--- a/dgit
+++ b/dgit
@@ -78,7 +78,7 @@ our $overwrite_version; # undef: not specified; '': check changelog
our $quilt_mode;
our $quilt_modes_re = 'linear|smash|auto|nofix|nocheck|gbp|dpm|unapplied';
our $dodep14tag;
-our $split_brain_save;
+our %internal_object_save;
our $we_are_responder;
our $we_are_initiator;
our $initiator_tempdir;
@@ -100,9 +100,6 @@ our %format_ok = map { $_=>1 } ("1.0","3.0 (native)","3.0 (quilt)");
our $suite_re = '[-+.0-9a-z]+';
our $cleanmode_re = 'dpkg-source(?:-d)?|git|git-ff|check|none';
-our $orig_f_comp_re = qr{orig(?:-$extra_orig_namepart_re)?};
-our $orig_f_sig_re = '\\.(?:asc|gpg|pgp)';
-our $orig_f_tail_re = "$orig_f_comp_re\\.tar(?:\\.\\w+)?(?:$orig_f_sig_re)?";
our $git_authline_re = '^([^<>]+) \<(\S+)\> (\d+ [-+]\d+)$';
our $splitbraincache = 'dgit-intern/quilt-cache';
@@ -201,15 +198,13 @@ sub lref () { return "refs/heads/".lbranch(); }
sub lrref () { return "refs/remotes/$remotename/".server_branch($csuite); }
sub rrref () { return server_ref($csuite); }
-sub stripepoch ($) {
- my ($vsn) = @_;
- $vsn =~ s/^\d+\://;
- return $vsn;
-}
-
sub srcfn ($$) {
- my ($vsn,$sfx) = @_;
- return "${package}_".(stripepoch $vsn).$sfx
+ my ($vsn, $sfx) = @_;
+ return &source_file_leafname($package, $vsn, $sfx);
+}
+sub is_orig_file_of_vsn ($$) {
+ my ($f, $upstreamvsn) = @_;
+ return is_orig_file_of_p_v($f, $package, $upstreamvsn);
}
sub dscfn ($) {
@@ -222,12 +217,6 @@ sub changespat ($;$) {
return "${package}_".(stripepoch $vsn)."_".($arch//'*').".changes";
}
-sub upstreamversion ($) {
- my ($vsn) = @_;
- $vsn =~ s/-[^-]+$//;
- return $vsn;
-}
-
our $us = 'dgit';
initdebug('');
@@ -1089,7 +1078,7 @@ sub canonicalise_suite_ftpmasterapi {
} qw(codename name);
push @matched, $entry;
}
- fail "unknown suite $isuite" unless @matched;
+ fail "unknown suite $isuite, maybe -d would help" unless @matched;
my $cn;
eval {
@matched==1 or die "multiple matches for suite $isuite\n";
@@ -1867,13 +1856,6 @@ sub is_orig_file_in_dsc ($$) {
return 1;
}
-sub is_orig_file_of_vsn ($$) {
- my ($f, $upstreamvsn) = @_;
- my $base = srcfn $upstreamvsn, '';
- return 0 unless $f =~ m/^\Q$base\E\.$orig_f_tail_re$/;
- return 1;
-}
-
# This function determines whether a .changes file is source-only from
# the point of view of dak. Thus, it permits *_source.buildinfo
# files.
@@ -3837,13 +3819,14 @@ sub madformat_wantfixup ($) {
sub maybe_split_brain_save ($$$) {
my ($headref, $dgitview, $msg) = @_;
# => message fragment "$saved" describing disposition of $dgitview
- return "commit id $dgitview" unless defined $split_brain_save;
+ my $save = $internal_object_save{'dgit-view'};
+ return "commit id $dgitview" unless defined $save;
my @cmd = (shell_cmd 'cd "$1"; shift', $maindir,
git_update_ref_cmd
"dgit --dgit-view-save $msg HEAD=$headref",
- $split_brain_save, $dgitview);
+ $save, $dgitview);
runcmd @cmd;
- return "and left in $split_brain_save";
+ return "and left in $save";
}
# An "infopair" is a tuple [ $thing, $what ]
@@ -5737,6 +5720,31 @@ END
close $fakedsc or die $!;
}
+sub quilt_fakedsc2unapplied ($$) {
+ my ($headref, $upstreamversion) = @_;
+ # must be run in the playground
+ # quilt_make_fake_dsc must have been called
+
+ 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("source package");
+ mktree_in_ud_here();
+
+ rmtree '.pc';
+
+ rmtree 'debian'; # git checkout commitish paths does not delete!
+ runcmd @git, qw(checkout -f), $headref, qw(-- debian);
+ my $unapplied=git_add_write_tree();
+ printdebug "fake orig tree object $unapplied\n";
+ return $unapplied;
+}
+
sub quilt_check_splitbrain_cache ($$) {
my ($headref, $upstreamversion) = @_;
# Called only if we are in (potentially) split brain mode.
@@ -5890,24 +5898,7 @@ sub quilt_fixup_multipatch ($$$) {
quilt_check_splitbrain_cache($headref, $upstreamversion);
return if $cachehit;
}
-
- 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("source package");
- mktree_in_ud_here();
-
- rmtree '.pc';
-
- rmtree 'debian'; # git checkout commitish paths does not delete!
- runcmd @git, qw(checkout -f), $headref, qw(-- debian);
- my $unapplied=git_add_write_tree();
- printdebug "fake orig tree object $unapplied\n";
+ my $unapplied=quilt_fakedsc2unapplied($headref, $upstreamversion);
ensuredir '.pc';
@@ -6549,6 +6540,24 @@ sub cmd_quilt_fixup {
build_maybe_quilt_fixup();
}
+sub cmd_print_unapplied_treeish {
+ badusage "incorrect arguments to dgit print-unapplied-treeish" if @ARGV;
+ my $headref = git_rev_parse('HEAD');
+ my $clogp = commit_getclogp $headref;
+ $package = getfield $clogp, 'Source';
+ $version = getfield $clogp, 'Version';
+ $isuite = getfield $clogp, 'Distribution';
+ $csuite = $isuite; # we want this to be offline!
+ notpushing();
+
+ prep_ud();
+ changedir $playground;
+ my $uv = upstreamversion $version;
+ quilt_make_fake_dsc($uv);
+ my $u = quilt_fakedsc2unapplied($headref, $uv);
+ print $u, "\n" or die $!;
+}
+
sub import_dsc_result {
my ($dstref, $newhash, $what_log, $what_msg) = @_;
my @cmd = (git_update_ref_cmd $what_log, $dstref, $newhash);
@@ -6952,10 +6961,13 @@ sub parseopts () {
} elsif (m/^--delayed=(\d+)$/s) {
push @ropts, $_;
push @dput, $_;
- } elsif (m/^--dgit-view-save=(.+)$/s) {
+ } elsif (my ($k,$v) =
+ m/^--save-(dgit-view)=(.+)$/s ||
+ m/^--(dgit-view)-save=(.+)$/s
+ ) {
push @ropts, $_;
- $split_brain_save = $1;
- $split_brain_save =~ s#^(?!refs/)#refs/heads/#;
+ $v =~ s#^(?!refs/)#refs/heads/#;
+ $internal_object_save{$k} = $v;
} elsif (m/^--(no-)?rm-old-changes$/s) {
push @ropts, $_;
$rmchanges = !$1;
diff --git a/dgit-maint-debrebase.7.pod b/dgit-maint-debrebase.7.pod
index 685a6b2..0f2f892 100644
--- a/dgit-maint-debrebase.7.pod
+++ b/dgit-maint-debrebase.7.pod
@@ -625,7 +625,12 @@ using git-rebase(1) directly. For example,
=back
If you take this approach, you should be very careful not to start the
-rebase too early.
+rebase too early,
+including before the most recent pseudomerge.
+git-rebase without a base argument will often
+start the rebase too early,
+and should be avoided.
+Run git-debrebase instead.
=head1 SEE ALSO
diff --git a/dgit.1 b/dgit.1
index a4b1694..a21f212 100644
--- a/dgit.1
+++ b/dgit.1
@@ -471,6 +471,26 @@ to cause it to exclude exactly the .git diredcory
and nothing else.
The separate arguments are unquoted, separated by spaces,
and do not contain spaces.
+.TP
+.B dgit print-unapplied-treeish
+Constructs a tree-ish approximating the patches-unapplied state
+of your 3.0 (quilt) package,
+and prints the git object name to stdout.
+This requires appropriate .orig tarballs.
+This tree object is identical to your .origs
+as regards upstream files.
+The contents of the debian subdirectory is not interesting
+and should not be inspected;
+except that debian/patches will be identical to your HEAD.
+
+To make this operate off-line,
+the access configuration key
+which is used to determine the build-products-dir
+is the uncanonicalised version of the suite name from the changelog,
+or (of course) dgit.default.build-products-dir.
+See ACCESS CONFIGURATION, below.
+
+This function is primarily provided for the benefit of git-debrebase.
.SH OPTIONS
.TP
.BR --dry-run " | " -n
@@ -661,7 +681,7 @@ Also,
it can mean that
dgit fails to find necessary git commits.
.TP
-.BR --dgit-view-save= \fIbranch\fR|\fIref\fR
+.BR --save-dgit-view= \fIbranch\fR|\fIref\fR
Specifies that when a split view quilt mode is in operation,
and dgit calculates
(or looks up in its cache)
@@ -681,6 +701,10 @@ And it is only effective with
If ref does not start with refs/
it is taken to to be a branch -
i.e. refs/heads/ is prepended.
+
+.B --dgit-view-save
+is a deprecated alias for
+--save-dgit-view.
.TP
.BI --deliberately- something
Declare that you are deliberately doing
diff --git a/git-debrebase b/git-debrebase
index 07e5f47..24be35e 100755
--- a/git-debrebase
+++ b/git-debrebase
@@ -36,6 +36,18 @@ use Dpkg::Version;
use File::FnMatch qw(:fnmatch);
use File::Copy;
+our ($usage_message) = <<'END';
+usages:
+ git-debrebase [<options>] [--|-i <git rebase options...>]
+ git-debrebase [<options>] status
+ git-debrebase [<options>] prepush [--prose=...]
+ git-debrebase [<options>] quick|conclude
+ git-debrebase [<options>] new-upstream <new-version> [<details ...>]
+ git-debrebase [<options>] convert-from-gbp [<upstream-commitish>]
+ ...
+See git-debrebase(1), git-debrebase(5), dgit-maint-debrebase(7) (in dgit).
+END
+
our ($opt_force, $opt_noop_ok, @opt_anchors);
our ($opt_defaultcmd_interactive);
@@ -45,10 +57,20 @@ $|=1;
sub badusage ($) {
my ($m) = @_;
- print STDERR "bad usage: $m\n";
+ print STDERR "$us: bad usage: $m\n";
finish 8;
}
+sub getoptions_main {
+ my $m = shift;
+ local $SIG{__WARN__}; # GetOptions calls `warn' to print messages
+ GetOptions @_ or badusage $m;
+}
+sub getoptions {
+ my $sc = shift;
+ getoptions_main "bad options follow \`git-debrebase $sc'", @_;
+}
+
sub cfg ($;$) {
my ($k, $optional) = @_;
local $/ = "\0";
@@ -92,6 +114,7 @@ our $rd;
our $workarea;
our @git = qw(git);
+our @dgit = qw(dgit);
sub in_workarea ($) {
my ($sub) = @_;
@@ -573,7 +596,8 @@ sub keycommits ($;$$$$) {
my ($anchor, $breakwater);
my $clogonly;
my $cl;
- $fatal //= sub { fail $_[2]; };
+ my $found_pm;
+ $fatal //= sub { fail $_[1]; };
my $x = sub {
my ($cb, $tagsfx, $mainwhy, $xwhy) = @_;
my $why = $mainwhy.$xwhy;
@@ -612,12 +636,20 @@ sub keycommits ($;$$$$) {
$breakwater = undef;
} elsif ($ty eq 'Pseudomerge' or
$ty eq 'AddPatches') {
+ my $found_pm = 1;
$x->($furniture, (lc $ty),
"found interchange bureaucracy commit ($ty)"," ($head)");
} elsif ($ty eq 'DgitImportUnpatched') {
- $x->($trouble, 'dgitimport',
- "found dgit dsc import ($head)");
- return (undef,undef);
+ if ($found_pm) {
+ $x->($trouble, 'dgitimport',
+ "found dgit dsc import"," ($head)");
+ return (undef,undef);
+ } else {
+ $x->($fatal, 'unprocessable',
+ "found bare dgit dsc import with no prior history",
+ " ($head)");
+ return (undef,undef);
+ }
} else {
$x->($fatal, 'unprocessable',
"found unprocessable commit, cannot cope: $cl->{Why}",
@@ -679,10 +711,11 @@ sub walk ($;$$) {
if ($nogenerate) {
return (undef,undef);
}
- die "commit $cur: Cannot cope with this commit (d.".
+ fail "found unprocessable commit, cannot cope".
+ (defined $cl->{Why} ? "; $cl->{Why}:": ':').
+ " (commit $cur) (d.".
(join ' ', map { sprintf "%#x", $_->{Differs} }
@{ $cl->{Parents} }).
- (defined $cl->{Why} ? "; $cl->{Why}": '').
")";
};
@@ -791,13 +824,12 @@ sub walk ($;$$) {
next;
} else {
# Everything is from this import. This kind of import
- # is already in valid breakwater format, with the
- # patches as commits.
- printf $report " NoPM" if $report;
- # last thing we processed will have been the first patch,
- # if there is one; which is fine, so no need to rewrite
- # on account of this import
- $build_start->("ImportOrigin", $cur);
+ # is already nearly in valid breakwater format, with the
+ # patches as commits. Unfortunately it contains
+ # debian/patches/.
+ printdebug "*** WALK BOMB bare dgit import\n";
+ $cl->{Why} = "bare dgit dsc import";
+ return $bomb->();
}
die "$ty ?";
} else {
@@ -943,6 +975,18 @@ sub update_head_postlaunder ($$$) {
runcmd @git, qw(rm --quiet --ignore-unmatch -rf debian/patches);
}
+sub currently_rebasing() {
+ foreach (qw(rebase-merge rebase-apply)) {
+ return 1 if stat_exists "$maindir_gitdir/$_";
+ }
+ return 0;
+}
+
+sub bail_if_rebasing() {
+ fail "you are in the middle of a git-rebase already"
+ if currently_rebasing();
+}
+
sub do_launder_head ($) {
my ($reflogmsg) = @_;
my $old = get_head();
@@ -1082,6 +1126,7 @@ sub record_ffq_prev_deferred () {
# if "deferred", will have added something about that to
# @deferred_update_messages, and also maybe printed (already)
# some messages about ff checks
+ bail_if_rebasing();
my $currentval = get_head();
my ($status,$message, $ffq_prev,$gdrlast) = ffq_check $currentval;
@@ -1105,6 +1150,7 @@ sub record_ffq_auto () {
}
sub ffq_prev_info () {
+ bail_if_rebasing();
# => ($ffq_prev, $gdrlast, $ffq_prev_commitish)
my ($status, $message, $current, $ffq_prev, $gdrlast)
= ffq_prev_branchinfo();
@@ -1161,6 +1207,34 @@ sub do_stitch ($;$) {
stitch($dangling_head, $ffq_prev, $gdrlast, $ffq_prev_commitish, $prose);
}
+sub upstream_commitish_search ($$) {
+ my ($upstream_version, $tried) = @_;
+ # todo: at some point maybe use git-deborig to do this
+ foreach my $tagpfx ('', 'v', 'upstream/') {
+ my $tag = $tagpfx.(dep14_version_mangle $upstream_version);
+ my $new_upstream = git_get_ref "refs/tags/$tag";
+ push @$tried, $tag;
+ return $new_upstream if length $new_upstream;
+ }
+}
+
+sub resolve_upstream_version ($$) {
+ my ($new_upstream, $upstream_version) = @_;
+
+ if (!defined $new_upstream) {
+ my @tried;
+ $new_upstream = upstream_commitish_search $upstream_version, \@tried;
+ if (!length $new_upstream) {
+ fail "Could not determine appropriate upstream commitish.\n".
+ " (Tried these tags: @tried)\n".
+ " Check version, and specify upstream commitish explicitly.";
+ }
+ }
+ $new_upstream = git_rev_parse $new_upstream;
+
+ return $new_upstream;
+}
+
sub cmd_new_upstream () {
# automatically and unconditionally launders before rebasing
# if rebase --abort is used, laundering has still been done
@@ -1172,28 +1246,15 @@ sub cmd_new_upstream () {
# parse args - low commitment
my $spec_version = shift @ARGV;
my $new_version = (new Dpkg::Version $spec_version, check => 1);
+ fail "bad version number \`$spec_version'" unless defined $new_version;
if ($new_version->is_native()) {
$new_version = (new Dpkg::Version "$spec_version-1", check => 1);
}
- my $new_upstream_version = $new_version->version();
my $new_upstream = shift @ARGV;
- if (!defined $new_upstream) {
- my @tried;
- # todo: at some point maybe use git-deborig to do this
- foreach my $tagpfx ('', 'v', 'upstream/') {
- my $tag = $tagpfx.(dep14_version_mangle $new_upstream_version);
- $new_upstream = git_get_ref "refs/tags/$tag";
- last if length $new_upstream;
- push @tried, $tag;
- }
- if (!length $new_upstream) {
- fail "Could not determine appropriate upstream commitish.\n".
- " (Tried these tags: @tried)\n".
- " Check version, and specify upstream commitish explicitly.";
- }
- }
- $new_upstream = git_rev_parse $new_upstream;
+ my $new_upstream_version = upstreamversion $new_version;
+ $new_upstream =
+ resolve_upstream_version $new_upstream, $new_upstream_version;
record_ffq_auto();
@@ -1500,11 +1561,13 @@ sub cmd_status () {
print " not git-debrebase (diverged since last stitch)\n"
}
}
+ print "you are currently rebasing\n" if currently_rebasing();
}
sub cmd_stitch () {
my $prose = 'stitch';
- GetOptions('prose=s', \$prose) or badusage("bad options to stitch");
+ getoptions("stitch",
+ 'prose=s', \$prose);
badusage "no arguments allowed" if @ARGV;
do_stitch $prose, 0;
}
@@ -1529,6 +1592,24 @@ sub cmd_conclude () {
do_stitch 'quick';
}
+sub cmd_scrap () {
+ if (currently_rebasing()) {
+ runcmd @git, qw(rebase --abort);
+ }
+ my ($ffq_prev, $gdrlast, $ffq_prev_commitish) = ffq_prev_info();
+ if (!$ffq_prev_commitish) {
+ fail "No ongoing git-debrebase session." unless $opt_noop_ok;
+ finish 0;
+ }
+ my $scrapping_head = get_head();
+ badusage "no arguments allowed" if @ARGV;
+ push @deferred_updates,
+ "update $gdrlast $ffq_prev_commitish $git_null_obj",
+ "update $ffq_prev $git_null_obj $ffq_prev_commitish";
+ snags_maybe_bail();
+ update_head_checkout $scrapping_head, $ffq_prev_commitish, "scrap";
+}
+
sub make_patches_staged ($) {
my ($head) = @_;
# Produces the patches that would result from $head if it were
@@ -1567,9 +1648,10 @@ sub make_patches ($) {
sub cmd_make_patches () {
my $opt_quiet_would_amend;
- GetOptions('quiet-would-amend!', \$opt_quiet_would_amend)
- or badusage("bad options to make-patches");
+ getoptions("make-patches",
+ 'quiet-would-amend!', \$opt_quiet_would_amend);
badusage "no arguments allowed" if @ARGV;
+ bail_if_rebasing();
my $old_head = get_head();
my $new = make_patches $old_head;
my $d = get_differs $old_head, $new;
@@ -1590,19 +1672,31 @@ sub cmd_make_patches () {
}
sub cmd_convert_from_gbp () {
- badusage "needs 1 optional argument, the upstream git rev"
+ badusage "want only 1 optional argument, the upstream git commitish"
unless @ARGV<=1;
+
+ my $clogp = parsechangelog();
+ my $version = $clogp->{'Version'}
+ // die "missing Version from changelog";
+
my ($upstream_spec) = @ARGV;
- $upstream_spec //= 'refs/heads/upstream';
- my $upstream = git_rev_parse $upstream_spec;
+
+ my $upstream_version = upstreamversion $version;
+ my $upstream =
+ resolve_upstream_version($upstream_spec, $upstream_version);
+
my $old_head = get_head();
my $upsdiff = get_differs $upstream, $old_head;
if ($upsdiff & D_UPS) {
- runcmd @git, qw(--no-pager diff),
+ runcmd @git, qw(--no-pager diff --stat),
$upstream, $old_head,
qw( -- :!/debian :/);
- fail "upstream ($upstream_spec) and HEAD are not identical in upstream files";
+ fail <<END;
+upstream ($upstream_spec) and HEAD are not
+identical in upstream files. See diffstat above, or run
+ git diff $upstream_spec HEAD -- :!/debian :/
+END
}
if (!is_fast_fwd $upstream, $old_head) {
@@ -1728,6 +1822,194 @@ git-debrebase: WARNING: doing so would drop all upstream patches!
END
}
+sub cmd_convert_from_dgit_view () {
+ my $clogp = parsechangelog();
+
+ my $bpd = (cfg 'dgit.default.build-products-dir',1) // '..';
+ my $do_origs = 1;
+ my $do_tags = 1;
+ my $always = 0;
+ my $diagnose = 0;
+
+ getoptions("convert-from-dgit-view",
+ 'diagnose!', \$diagnose,
+ 'build-products-dir:s', \$bpd,
+ 'origs!', \$do_origs,
+ 'tags!', \$do_tags,
+ 'always-convert-anyway!', \$always);
+ fail "takes 1 optional argument, the upstream commitish" if @ARGV>1;
+
+ my @upstreams;
+
+ if (@ARGV) {
+ my $spec = shift @ARGV;
+ my $commit = git_rev_parse "$spec^{commit}";
+ push @upstreams, { Commit => $commit,
+ Source => "$ARGV[0], from command line",
+ Only => 1,
+ };
+ }
+
+ my $head = get_head();
+
+ if (!$always) {
+ my $troubles = 0;
+ my $trouble = sub { $troubles++; };
+ keycommits $head, sub{}, sub{}, $trouble, $trouble;
+ printdebug "troubles=$troubles\n";
+ if (!$troubles) {
+ print STDERR <<END;
+$us: Branch already seems to be in git-debrebase format!
+$us: --always-convert-anyway would do the conversion operation anyway
+$us: but is probably a bad idea. Probably, you wanted to do nothing.
+END
+ fail "Branch already in git-debrebase format." unless $opt_noop_ok;
+ finish 0;
+ }
+ }
+
+ snags_maybe_bail_early();
+
+ my $version = upstreamversion $clogp->{Version};
+ print STDERR "Considering possible commits corresponding to upstream:\n";
+
+ if (!@upstreams) {
+ if ($do_tags) {
+ my @tried;
+ my $ups_tag = upstream_commitish_search $version, \@tried;
+ if ($ups_tag) {
+ my $this = "git tag $tried[-1]";
+ push @upstreams, { Commit => $ups_tag,
+ Source => $this,
+ };
+ } else {
+ printf STDERR
+ " git tag: no suitable tag found (tried %s)\n",
+ "@tried";
+ }
+ }
+ if ($do_origs) {
+ my $p = $clogp->{'Source'};
+ # we do a quick check to see if there are plausible origs
+ my $something=0;
+ if (!opendir BPD, $bpd) {
+ die "$bpd: opendir: $!" unless $!==ENOENT;
+ } else {
+ while ($!=0, my $f = readdir BPD) {
+ next unless is_orig_file_of_p_v $f, $p, $version;
+ printf STDERR
+ " orig: found what looks like a .orig, %s\n",
+ "$bpd/$f";
+ $something=1;
+ last;
+ }
+ die "read $bpd: $!" if $!;
+ closedir BPD;
+ }
+ if ($something) {
+ my $tree = cmdoutput
+ @dgit, qw(--build-products-dir), $bpd,
+ qw(print-unapplied-treeish);
+ fresh_workarea();
+ in_workarea sub {
+ runcmd @git, qw(reset --quiet), $tree, qw(-- .);
+ rm_subdir_cached 'debian';
+ $tree = cmdoutput @git, qw(write-tree);
+ my $ups_synth = make_commit [], [ <<END, <<END,
+Import effective orig tree for upstream version $version
+END
+This includes the contents of the .orig(s), minus any debian/ directory.
+
+[git-debrebase import-from-dgit-view upstream-import-convert: $version]
+END
+ ];
+ push @upstreams, { Commit => $ups_synth,
+ Source => "orig(s) imported via dgit",
+ };
+ }
+ } else {
+ printf STDERR
+ " orig: no suitable origs found (looked for %s in %s)\n",
+ "${p}_".(stripeoch $version)."...", $bpd;
+ }
+ }
+ }
+
+ my $some_patches = stat_exists 'debian/patches/series';
+
+ print STDERR "Evaluating possible commits corresponding to upstream:\n";
+
+ my $result;
+ foreach my $u (@upstreams) {
+ my $work = $head;
+ fresh_workarea();
+ in_workarea sub {
+ runcmd @git, qw(reset --quiet), $u->{Commit}, qw(-- .);
+ runcmd @git, qw(checkout), $u->{Commit}, qw(-- .);
+ runcmd @git, qw(clean -xdff);
+ runcmd @git, qw(checkout), $head, qw(-- debian);
+ if ($some_patches) {
+ rm_subdir_cached 'debian/patches';
+ $work = make_commit [ $work ], [
+ 'git-debrebase convert-from-dgit-view: drop upstream changes from breakwater',
+ "Drop upstream changes, and delete debian/patches, as part of converting\n".
+ "to git-debrebase format. Upstream changes will appear as commits.",
+ '[git-debrebase convert-from-dgit-view: drop patches from tree]'
+ ];
+ }
+ $work = make_commit [ $work, $u->{Commit} ], [
+ 'git-debrebase convert-from-dgit-view: declare upstream',
+ '(Re)constructed breakwater merge.',
+ '[git-debrebase anchor: declare upstream]'
+ ];
+ runcmd @git, qw(checkout --quiet -b mk), $work;
+ if ($some_patches) {
+ runcmd @git, qw(checkout), $head, qw(-- debian/patches);
+ runcmd @git, qw(reset --quiet);
+ my @gbp_cmd = (qw(gbp pq import));
+ if (!$diagnose) {
+ my $gbp_err = "../gbp-pq-err";
+ @gbp_cmd = shell_cmd "exec >$gbp_err 2>&1", @gbp_cmd;
+ }
+ my $r = system @gbp_cmd;
+ if ($r) {
+ printf STDERR
+ " %s: couldn't apply patches: gbp pq %s",
+ $u->{Source}, waitstatusmsg();
+ return;
+ }
+ }
+ my $work = git_rev_parse qw(HEAD);
+ my $diffout = cmdoutput @git, qw(diff-tree --stat HEAD), $work;
+ if (length $diffout) {
+ print STDERR
+ " $u->{Source}: applying patches gives different tree\n";
+ print STDERR $diffout if $diagnose;
+ return;
+ }
+ # OMG!
+ $u->{Result} = $work;
+ $result = $u;
+ };
+ last if $result;
+ }
+
+ if (!$result) {
+ fail <<END;
+Could not find or construct a suitable upstream commit.
+Rerun adding --diagnose after convert-from-dgit-view, or pass a
+upstream commmit explicitly or provide suitable origs.
+END
+ }
+
+ printf STDERR "Yes, will base new branch on %s\n", $result->{Source};
+
+ ffq_check $result->{Result};
+ snags_maybe_bail();
+ update_head_checkout $head, $result->{Result},
+ 'convert-from-dgit-view';
+}
+
sub cmd_downstream_rebase_launder_v0 () {
badusage "needs 1 argument, the baseline" unless @ARGV==1;
my ($base) = @ARGV;
@@ -1777,10 +2059,13 @@ sub cmd_downstream_rebase_launder_v0 () {
}
}
-GetOptions("D+" => \$debuglevel,
+getoptions_main
+ ("bad options\n",
+ "D+" => \$debuglevel,
'noop-ok', => \$opt_noop_ok,
'f=s' => \@snag_force_opts,
'anchor=s' => \@opt_anchors,
+ '--dgit=s' => \($dgit[0]),
'force!',
'-i:s' => sub {
my ($opt,$val) = @_;
@@ -1793,7 +2078,10 @@ GetOptions("D+" => \$debuglevel,
# approach. '-i=s{0,}' does not work with bundling.
push @$opt_defaultcmd_interactive, @ARGV;
@ARGV=();
- }) or badusage "bad options\n";
+ },
+ 'help' => sub { print $usage_message or die $!; finish 0; },
+ );
+
initdebug('git-debrebase ');
enabledebug if $debuglevel;
diff --git a/git-debrebase.1.pod b/git-debrebase.1.pod
index 273ef47..fe65674 100644
--- a/git-debrebase.1.pod
+++ b/git-debrebase.1.pod
@@ -55,6 +55,12 @@ The options for git-rebase must either start with C<-i>,
or be prececded by C<-->,
to distinguish them from options for git-debrebase.
+It is hazardous to use plain git-rebase on a git-debrebase branch,
+because git-rebase has a tendency to start the rebase
+too far back in history,
+and then drop important commits.
+Soo L<git-debrebase(5)/ILLEGAL OPERATIONS>
+
=item git-debrebase status
Analyses the current branch,
@@ -100,6 +106,13 @@ If there is no ffq-prev, it is an error, unless --noop-ok.
You should consider using B<conclude> instead,
because that launders the branch too.
+=item git-debrebase scrap
+
+Throws away all the work since the branch was last stitched.
+This is done by rewinding you to ffq-prev.
+
+If you are in the middle of a git-rebase, will abort that too.
+
=item git-debrebase new-upstream <new-version> [<upstream-details>...]
Rebases the delta queue
@@ -250,6 +263,8 @@ the gbp upstream branch, if there is one.
It is a snag if it is not an ancestor of HEAD,
or if the history between the upstream and HEAD
contains commits which make changes to upstream files.
+If it is not specified,
+the same algorithm is used as for git-debrebase new-upstream.
It is also a snag if the specified upstream
has a debian/ subdirectory.
@@ -270,7 +285,7 @@ just as for a laundering/unstitching call to git-debrebase;
See L</Establish the current branch's ffq-prev>, below.
Note that it is dangerous not to know whether you are
-dealing with a gbp patches-unappled branch containing quilt patches,
+dealing with a gbp patches-unapplied branch containing quilt patches,
or a git-debrebase interchange branch.
At worst,
using the wrong tool for the branch format might result in
@@ -335,6 +350,72 @@ Be sure to not accidentally treat the result as
a git-debrebase branch,
or you will drop all the patches!
+=item git-debrebase convert-from-dgit-view [<convert-options>] [upstream]
+
+Converts any dgit-compatible git branch
+corresponding to a (possibly hypothetical) 3.0 quilt dsc source package
+into a git-debrebase-compatible branch.
+
+This operation should not be used
+if the branch is already in git-debrebase form.
+Normally git-debrebase will refuse to continue in this case
+(or silently do nothing if the global --noop-ok option is used).
+
+Some representation of the original upstream source code will be needed.
+If I<upstream> is supplied, that must be a suitable upstream commit.
+By default,
+git-debrebase will look first for git tags (as for new-upstream),
+and then for orig tarballs which it will ask dgit to process.
+
+The upstream source must be exactly right and
+all the patches in debian/patches must be up to date.
+Applying the patches from debian/patches to the upstream source
+must result in exactly your HEAD.
+
+The output is laundered and stitched.
+The resulting history is not particularly pretty,
+especially if orig tarball(s) were imported
+to produce a synthetic upstream commit.
+
+The available convert-options are as follows.
+(These must come after convert-from-dgit-view.)
+
+=over
+
+=item --[no-]diagnose
+
+Print additional error messages to help diagnose
+failure to find an appropriate upstream.
+--no-diagnose is the default.
+
+=item --build-products-dir
+
+Directory to look in for orig tarballs.
+The default is the git config option
+dgit.default.build-products-dir
+or failing that, C<..>.
+Passed on to dgit, if git-debrebase invokes dgit.
+
+=item --[no-]origs
+
+Whether to try to look for or use any orig tarballs.
+--origs is the default.
+
+=item --[no-]tags
+
+Whether to try to look for or use any upstream git tags.
+--tags is the default.
+
+=item --always-convert-anyway
+
+Perform the conversion operation,
+producing unpleasant extra history,
+even if the branch seems to be in git-debrebase form already.
+This should not be done unless necessary,
+and it should not be necessary.
+
+=back
+
=back
=head1 OPTIONS
@@ -399,6 +480,12 @@ it is a snag if <commit-ish> is the anchor
for the previous upstream version in
git-debrebase new-upstream operations.
+=item --dgit=<program>
+
+Run <program>, instead of dgit from PATH,
+when invocation of dgit is necessary.
+This is provided mostly for the benefit of the test suite.
+
=item -D
Requests (more) debugging. May be repeated.
diff --git a/git-debrebase.5.pod b/git-debrebase.5.pod
index 52fb60b..d39ad94 100644
--- a/git-debrebase.5.pod
+++ b/git-debrebase.5.pod
@@ -487,6 +487,48 @@ These patch files can be stripped out and/or regenerated as needed.
=back
+=head1 ILLEGAL OPERATIONS
+
+Some git operations are not permitted in this data model.
+Performing them will break git-debrebase.
+
+=over
+
+=item General merges
+
+See L</OTHER MERGES>, above.
+
+=item git-rebase starting too soon, or without base argument
+
+git-rebase must not be invoked in such a way that
+the chosen base is before the anchor,
+or before the last pseudomerge.
+This is because git-rebase mangles merges.
+git rebase --preserve-merges is also dangerous.
+
+git-rebase without a base argument will often start too early.
+
+For these reasons,
+it is better to use git-debrebase and
+let it choose the base
+for your rebase.
+If you do realise you have make this mistake,
+it is best to use the reflog to recover to a suitable
+good previous state.
+
+=item Editing debian/patches
+
+debian/patches is an output from git-debrebase,
+not an input.
+If you edit patches git-debrebase will complain
+and refuse to work.
+If you add patches your work is likely to be discarded.
+
+Instead of editing patches,
+use git-debrebase to edit the corresponding commits.
+
+=back
+
=head1 COMMIT MESSAGE ANNOTATIONS
git-debrebase makes annotations
diff --git a/tests/Makefile b/tests/Makefile
index 8494284..88bc0a0 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -9,7 +9,7 @@ TESTNAMES := $(notdir $(TESTSCRIPTS))
all: $(foreach t,$(TESTNAMES),tests/tmp/$t.ok)
@echo "ALL PASSED$${DGIT_TESTS_PROGRESSIVE+ AT SOME POINT}"
-tests/tmp/%.ok:
+tests/tmp/%.ok: tests/tests/%
ifeq ($(DGIT_TEST_RETRY_COUNT),)
tests/tests/$* >tests/tmp/$*.log 2>&1
else
diff --git a/tests/lib-gdr b/tests/lib-gdr
index 95d2330..479ef41 100644
--- a/tests/lib-gdr
+++ b/tests/lib-gdr
@@ -7,7 +7,8 @@ t-git-debrebase () {
local gdr=${DGIT_GITDEBREBASE_TEST-git-debrebase}
: '
{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{'
- $gdr $GDR_TEST_OPTS $GDR_TEST_DEBUG $t_gdr_xopts "$@"
+ $gdr "--dgit=${DGIT_TEST-dgit}" $GDR_TEST_OPTS \
+ $GDR_TEST_DEBUG $t_gdr_xopts "$@"
: '}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
'
}
diff --git a/tests/setup/gdr-convert-gbp b/tests/setup/gdr-convert-gbp
index 6ec374d..a3baf2d 100755
--- a/tests/setup/gdr-convert-gbp
+++ b/tests/setup/gdr-convert-gbp
@@ -11,6 +11,7 @@ t-dependencies GDR
t-tstunt-parsechangelog
not-gdr-processable () {
+ git branch gdr-unprocessable/$1
t-git-debrebase analyse | grep 'Unknown Unprocessable'
}
@@ -37,7 +38,7 @@ gbp pq export
git add debian/patches
git commit -m "patch queue update ($0)"
-not-gdr-processable
+not-gdr-processable origin
: 'fake up an upstream 2.0'
git branch make-upstream upstream
@@ -61,7 +62,7 @@ done
git checkout master
gbp import-orig --upstream-version=2.0 ../$ust
-not-gdr-processable
+not-gdr-processable merge
t-dch-commit -v 2.0-1 -m 'new upstream (did gbp import-orig)'
t-dch-commit-r
@@ -80,6 +81,9 @@ git push --set-upstream origin master
# debian/2.0-1 archive/debian/2.0-1
# remotes/origin/master remotes/dgit/dgit/sid
+t-expect-fail E:'identical in upstream files' \
+t-git-debrebase -fupstream-has-debian convert-from-gbp upstream/2.0~
+
t-git-debrebase -fupstream-has-debian convert-from-gbp
v=2.0-2
diff --git a/tests/tests/gdr-diverge-nmu b/tests/tests/gdr-diverge-nmu
index 15bf901..82aeaa5 100755
--- a/tests/tests/gdr-diverge-nmu
+++ b/tests/tests/gdr-diverge-nmu
@@ -4,6 +4,7 @@ set -e
t-dependencies GDR
+t-tstunt-parsechangelog
t-setup-import gdr-convert-gbp
cd $p
diff --git a/tests/tests/gdr-edits b/tests/tests/gdr-edits
index 52c083b..124de29 100755
--- a/tests/tests/gdr-edits
+++ b/tests/tests/gdr-edits
@@ -4,6 +4,7 @@ set -e
t-dependencies GDR
+t-tstunt-parsechangelog
t-setup-import gdr-convert-gbp
cd $p
diff --git a/tests/tests/gdr-import-dgit b/tests/tests/gdr-import-dgit
index c18c097..e58ff32 100755
--- a/tests/tests/gdr-import-dgit
+++ b/tests/tests/gdr-import-dgit
@@ -4,6 +4,7 @@ set -e
t-dependencies GDR
+t-tstunt-parsechangelog
t-setup-import gdr-convert-gbp
cd $p
diff --git a/tests/tests/gdr-import-dgitview b/tests/tests/gdr-import-dgitview
new file mode 100755
index 0000000..3670deb
--- /dev/null
+++ b/tests/tests/gdr-import-dgitview
@@ -0,0 +1,45 @@
+#!/bin/bash
+set -e
+. tests/lib
+. $troot/lib-gdr
+
+t-dependencies GDR
+
+t-tstunt-parsechangelog
+
+t-archive example 1.0-1
+t-git-none
+
+t-dgit clone $p
+
+cd $p
+
+t-git-debrebase status
+
+t-expect-fail E:'bare dgit dsc import' \
+t-git-debrebase
+
+LC_MESSAGES=C t-git-debrebase status |tee ../bare-output
+grep 'bare dgit dsc import with no prior history' ../bare-output
+
+git branch before
+
+t-expect-fail E:'Could not find or construct a suitable upstream commit' \
+t-git-debrebase convert-from-dgit-view --no-origs
+
+t-git-debrebase convert-from-dgit-view
+t-gdr-good laundered
+
+t-expect-fail E:'already seems to be in git-debrebase format' \
+t-git-debrebase convert-from-dgit-view
+
+t-refs-same-start
+t-ref-head
+t-git-debrebase --noop-ok convert-from-dgit-view
+t-ref-head
+
+t-git-debrebase convert-from-dgit-view --always-convert-anyway
+t-expect-fail E:'ref varies' t-ref-head
+t-gdr-good laundered
+
+t-ok
diff --git a/tests/tests/gdr-makepatches7 b/tests/tests/gdr-makepatches7
index 02ea7ab..52462d4 100755
--- a/tests/tests/gdr-makepatches7
+++ b/tests/tests/gdr-makepatches7
@@ -4,6 +4,7 @@ set -e
t-dependencies GDR
+t-tstunt-parsechangelog
t-setup-import gdr-convert-gbp
cd $p
diff --git a/tests/tests/gdr-newupstream b/tests/tests/gdr-newupstream
index 39ed24b..ada5516 100755
--- a/tests/tests/gdr-newupstream
+++ b/tests/tests/gdr-newupstream
@@ -5,6 +5,7 @@ autoimport=
t-dependencies NO-DGIT GDR
+t-tstunt-parsechangelog
t-setup-import gdr-convert-gbp-noarchive
cd $p
diff --git a/tests/tests/gdr-subcommands b/tests/tests/gdr-subcommands
index e59fc07..b4d8f44 100755
--- a/tests/tests/gdr-subcommands
+++ b/tests/tests/gdr-subcommands
@@ -4,6 +4,7 @@ set -e
t-dependencies GDR
+t-tstunt-parsechangelog
t-setup-import gdr-convert-gbp
cd $p
@@ -34,10 +35,12 @@ mix-it
git checkout -b unstitched-laundered master
mix-it
+git branch before-unstitch/unstitched-laundered
t-git-debrebase
t-gdr-good laundered
git checkout -b unstitched-mixed master
+git branch before-unstitch/unstitched-mixed
t-git-debrebase
mix-it
@@ -172,6 +175,12 @@ make_check () {
f*)
t-has-ancestor HEAD refs/heads/$before
;;
+ Z*)
+ t-refs-same-start
+ t-refs-same refs/heads/$work
+ t-refs-same refs/heads/before-unstitch/$startbranch
+ t-ref-head
+ ;;
*)
fail "$1"
;;
@@ -194,8 +203,8 @@ subcmd stitch Ns Nu Sltf Stf
subcmd prepush Ns Nu Sltf Stf
subcmd quick ns Sl Sltf Sl
subcmd conclude "$Ec" "$Ec" Sltf Sl
+subcmd scrap Ns Ns Z Z
subcmd make-patches sPft "$Ep" uPft "$Ep"
-#subcmd dgit-upload-hook Psft "$Ep" SPft "$Ep"
#
# result codes, each one is a check:
# E:$pat } this is an error (must come first)
@@ -214,6 +223,7 @@ subcmd make-patches sPft "$Ep" uPft "$Ep"
# V ffq-prev remains unchanged; implies also u
# s result is stitched, debrebase-last exists and is unchanged
# S result is stitch just made, remaining letters apply to result~
+# Z result is rewind to before changes made
#
# P result is add-patches, remaining letters apply to result~
#
diff --git a/tests/tests/gdr-unprocessable b/tests/tests/gdr-unprocessable
new file mode 100755
index 0000000..14d1e8e
--- /dev/null
+++ b/tests/tests/gdr-unprocessable
@@ -0,0 +1,61 @@
+#!/bin/bash
+set -e
+. tests/lib
+
+t-dependencies GDR
+
+t-tstunt-parsechangelog
+t-setup-import gdr-convert-gbp
+
+cd $p
+
+t-dgit setup-mergechangelogs
+
+subcmd () {
+ cmd=("$@")
+
+ branch merge 'complex merge'
+ branch origin 'origin commit'
+}
+
+branch () {
+ branch=$1
+ git checkout gdr-unprocessable/$branch
+ msgcore=$2
+ expected-$expected
+}
+
+cmd () {
+ t-git-debrebase "${cmd[@]}"
+}
+
+expected- () {
+ t-expect-fail E:"$(printf "$mfmt" "$msgcore")" \
+ cmd
+}
+
+expected-ok () {
+ f=../out.$branch."${cmd/[^-a-zA-Z//_}"
+ cmd | tee $f
+ for mfmt in "${mfmts[@]}"; do
+ grep "$(printf "$mfmt" "$msgcore")" $f
+ done
+}
+
+mfmt='found unprocessable commit.*%s'
+subcmd
+subcmd quick
+subcmd new-upstream 2.0 upstream/2.0
+subcmd make-patches
+subcmd breakwater
+subcmd anchor
+
+expected=ok
+mfmts=(' Unprocessable (%s)')
+subcmd analyse
+
+mfmts=('branch not in git-debrebase form'
+ 'found unprocessable commit, cannot cope: %s')
+subcmd status
+
+t-ok
diff --git a/tests/tests/gdr-viagit b/tests/tests/gdr-viagit
index a83e622..0495eb1 100755
--- a/tests/tests/gdr-viagit
+++ b/tests/tests/gdr-viagit
@@ -5,6 +5,7 @@ autoimport=
t-dependencies NO-DGIT GDR
+t-tstunt-parsechangelog
t-setup-import gdr-convert-gbp-noarchive
: 'set up so t-git-debrebase runs gdr via git'
@@ -38,4 +39,18 @@ t-gdr-good laundered
t-git-debrebase stitch --prose=wombat
t-gdr-good stitched
+: ----- test scrap -----
+
+t-refs-same-start
+t-ref-head
+
+t-git-debrebase
+t-gdr-good laundered
+
+t-some-changes
+t-git-debrebase scrap
+t-gdr-good stitched
+
+t-ref-head
+
t-ok