From 528ff0071b6e9d1db499b48897a4a13f581f254f Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 10 Feb 2018 12:21:39 +0000 Subject: [PATCH] git-debrebase: wip gbp2debrebase Signed-off-by: Ian Jackson --- git-debrebase | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/git-debrebase b/git-debrebase index b70f8d91..50f5e167 100755 --- a/git-debrebase +++ b/git-debrebase @@ -990,6 +990,45 @@ END # now it's for the user to sort out } +sub cmd_gbp2debrebase () { + badusage "needs 1 optional argument, the upstream" unless @ARGV<=1; + my ($upstream_spec) = @ARGV; + $upstream_spec //= 'refs/heads/upstream'; + my $upstream = git_rev_parse $upstream_spec; + my $old_head = get_head(); + + my $upsdiff = get_differs $upstream, $old_head; + if ($upsdiff & D_UPS) { + runcmd @git, qw(--no-pager diff), + $upstream, $old_head, + qw( -- :!/debian :/); + fail "upstream ($upstream_spec) and HEAD are not identical in upstream files"; + } + + if (!is_fast_fwd $upstream, $old_head) { + fproblem "upstream ($upstream) is not an ancestor of HEAD"; + } else { + my $wrong = cmdoutput + (@git, qw(rev-list --ancestry-path), "$upstream..HEAD", + qw(-- :/ :!/debian)); + if (length $wrong) { + fproblem "history between upstream ($upstream) and HEAD contains direct changes to upstream files - are you sure this is a gbp (patches-unapplied) branch?"; + print STDERR "list expected changes with: git log --stat --ancestry-path $upstream_spec..HEAD -- :/ ':!/debian'\n"; + } + } + + if ((git_cat_file "$upstream:debian")[0] ne 'missing') { + fproblem "upstream ($upstream) contains debian/ directory"; + } + die; + + fresh_workarea(); + in_workarea sub { + runcmd @git, qw(checkout -b work), $old_head; + + }; +} + sub cmd_downstream_rebase_launder_v0 () { badusage "needs 1 argument, the baseline" unless @ARGV==1; my ($base) = @ARGV; -- 2.30.2