From 6b3cdcf0d595efd96bc8c4220df87f7fd5aaef76 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Mon, 23 Apr 2018 00:32:43 +0100 Subject: git-debrebase: Implement make-patches Signed-off-by: Ian Jackson --- git-debrebase | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'git-debrebase') diff --git a/git-debrebase b/git-debrebase index 7d5d5bd..7c8d54d 100755 --- a/git-debrebase +++ b/git-debrebase @@ -1362,6 +1362,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; -- cgit v1.2.3