X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=dgit.git;a=blobdiff_plain;f=git-debrebase;h=87928bc55db59739c1ec7875826f1969e48641a9;hp=50f5e1674c6574afa7d42c8e7d04a33c31b99867;hb=1f4480c7fe42d8e997db608c35a3500de1052528;hpb=528ff0071b6e9d1db499b48897a4a13f581f254f diff --git a/git-debrebase b/git-debrebase index 50f5e167..87928bc5 100755 --- a/git-debrebase +++ b/git-debrebase @@ -162,7 +162,7 @@ sub get_differs ($$) { my @cmd = (@git, qw(diff-tree -z --no-renames)); push @cmd, @$opts; push @cmd, "$_:" foreach $x, $y; - push @cmd, @$limits; + push @cmd, '--', @$limits; my $diffs = cmdoutput @cmd; foreach (split /\0/, $diffs) { $fn->(); } }; @@ -492,10 +492,11 @@ sub walk ($;$$) { my $cl; my $xmsg = sub { - my ($appendinfo) = @_; + my ($prose, $info) = @_; my $ms = $cl->{Msg}; chomp $ms; - $ms .= "\n\n[git-debrebase $appendinfo]\n"; + $info //= ''; + $ms .= "\n\n[git-debrebase$info: $prose]\n"; return (Msg => $ms); }; my $rewrite_from_here = sub { @@ -628,7 +629,8 @@ sub walk ($;$$) { push @brw_cl, { %$cl, SpecialMethod => 'DgitImportUpstreamUpdate', - $xmsg->("convert dgit import: upstream changes") + $xmsg->("convert dgit import: upstream changes", + " breakwater") }; } $prline->(" Import"); @@ -770,9 +772,8 @@ sub update_head ($$$) { sub update_head_checkout ($$$) { my ($old, $new, $mrest) = @_; - my $symref = git_get_symref(); - runcmd @git, qw(checkout), $new, qw(.); update_head $old, $new, $mrest; + runcmd @git, qw(reset --hard); } sub update_head_postlaunder ($$$) { @@ -877,7 +878,7 @@ sub cmd_new_upstream_v0 () { if ($old_upstream->{Msg} =~ m{^\[git-debrebase }m) { if ($old_upstream->{Msg} =~ - m{^\[git-debrebase (?:\w*-)?upstream combine \.((?: $extra_orig_namepart_re)+)\]} + m{^\[git-debrebase upstream-combine \.((?: $extra_orig_namepart_re)+)\:.*\]$}m ) { my @oldpieces = ('', split / /, $1); my $parentix = -1 + scalar @{ $old_upstream->{Parents} }; @@ -887,7 +888,7 @@ sub cmd_new_upstream_v0 () { } } else { fproblem "previous upstream $old_upstream->{CommitId} is from". - " git-debrebase but not an \`upstream combine' commit"; + " git-debrebase but not an \`upstream-combine' commit"; } } @@ -931,9 +932,9 @@ sub cmd_new_upstream_v0 () { # need to make the upstream subtree merge commit $new_upstream = make_commit \@upstream_merge_parents, [ "Combine upstreams for $new_upstream_version", - ("[git-debrebase new-upstream combine . ". - (join " ", map { $_->{Name} } @newpieces[1..$#newpieces]). - "]"), + ("[git-debrebase upstream-combine . ". + (join " ", map { $_->{Name} } @newpieces[1..$#newpieces]). + ": new upstream]"), ]; } @@ -946,7 +947,7 @@ sub cmd_new_upstream_v0 () { # index now contains the breakwater merge contents $new_bw = make_commit [ $old_bw, $new_upstream ], [ "Update to upstream $new_upstream_version", - "[git-debrebase new-upstream breakwater $new_upstream_version]", + "[git-debrebase breakwater: new upstream $new_upstream_version, merge]", ]; # Now we have to add a changelog stanza so the Debian version @@ -974,7 +975,7 @@ END # Now we have the final new breakwater branch in the index $new_bw = make_commit [ $new_bw ], [ "Update changelog for new upstream $new_upstream_version", - "[git-debrebase new-upstream changelog $new_upstream_version]", + "[git-debrebase: new upstream $new_upstream_version, changelog]", ]; }; @@ -1020,13 +1021,39 @@ sub cmd_gbp2debrebase () { if ((git_cat_file "$upstream:debian")[0] ne 'missing') { fproblem "upstream ($upstream) contains debian/ directory"; } - die; + + fproblems_maybe_bail(); + + my $work; fresh_workarea(); in_workarea sub { - runcmd @git, qw(checkout -b work), $old_head; - + runcmd @git, qw(checkout -q -b gdr-internal), $old_head; + # make a branch out of the patch queue - we'll want this in a mo + runcmd qw(gbp pq import); + # strip the patches out + runcmd @git, qw(checkout -q gdr-internal~0); + rm_subdir_cached 'debian/patches'; + $work = make_commit ['HEAD'], [ + 'git-debrebase import: drop patch queue', + 'Delete debian/patches, as part of converting to git-debrebase format.', + '[git-debrebase: gbp2debrebase, drop patches]' + ]; + # make the breakwater pseudomerge + # the tree is already exactly right + $work = make_commit [$work, $upstream], [ + 'git-debrebase import: declare upstream', + 'First breakwater merge.', + '[git-debrebase breakwater: declare upstream]' + ]; + + # rebase the patch queue onto the new breakwater + runcmd @git, qw(reset --quiet --hard patch-queue/gdr-internal); + runcmd @git, qw(rebase --quiet --onto), $work, qw(gdr-internal); + $work = get_head(); }; + + update_head_checkout $old_head, $work, 'gbp2debrebase'; } sub cmd_downstream_rebase_launder_v0 () {