X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=dgit.git;a=blobdiff_plain;f=git-debrebase;h=bf9af61627bfc2f5bbd85c87417eec7e2a6c7d42;hp=7d5d5bdd72254bc0dcbac180037d0355095d58cb;hb=223328e90bbec5bd8a0c55bf1a0f0f609e8154ac;hpb=297ff51a0df2098ea9fe088e229bcd1318bfe466 diff --git a/git-debrebase b/git-debrebase index 7d5d5bdd..bf9af616 100755 --- a/git-debrebase +++ b/git-debrebase @@ -18,6 +18,9 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +END { $? = $Debian::Dgit::ExitStatus::desired // -1; }; +use Debian::Dgit::ExitStatus; + use strict; use Debian::Dgit qw(:DEFAULT :playground); @@ -39,7 +42,7 @@ our $us = qw(git-debrebase); sub badusage ($) { my ($m) = @_; print STDERR "bad usage: $m\n"; - exit 12; + finish 12; } sub cfg ($;$) { @@ -1362,6 +1365,44 @@ sub make_patches_staged ($) { }; } +sub make_patches ($) { + my ($head) = @_; + keycommits $head, 0, \&snag; + make_patches_staged $head; + my $out; + in_workarea sub { + my $ptree = cmdoutput @git, qw(write-tree --prefix=debian/patches/); + runcmd @git, qw(read-tree), $head; + read_tree_subdir 'debian/patches', $ptree; + $out = make_commit [$head], [ + 'Commit patch queue (exported by git-debrebase)', + '[git-debrebase: export and commit patches]', + ]; + }; + my $d = get_differs $head, $out; + if ($d == 0) { + return undef; # nothing to do + } elsif ($d == D_PAT_ADD) { + return $out; # OK + } else { + fail "Patch export produced patch amendments". + " (abandoned output commit $out).". + " Try laundering first."; + } +} + +sub cmd_make_patches () { + badusage "no arguments allowed" if @ARGV; + my $old_head = get_head(); + my $new = make_patches $old_head; + snags_maybe_bail(); + if (!$new) { + fail "No (more) patches to export." unless $opt_noop_ok; + return; + } + update_head_checkout $old_head, $new, 'make-patches'; +} + sub cmd_convert_from_gbp () { badusage "needs 1 optional argument, the upstream git rev" unless @ARGV<=1; @@ -1544,3 +1585,5 @@ if (!@ARGV || $opt_defaultcmd_interactive || $ARGV[0] =~ m{^-}) { $cmdfn or badusage "unknown git-debrebase sub-operation $cmd"; $cmdfn->(); } + +finish 0;