chiark / gitweb /
git-debrebase: bugfixes
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 10 Feb 2018 14:15:09 +0000 (14:15 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 16 Jun 2018 11:25:49 +0000 (12:25 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
git-debrebase

index 50f5e1674c6574afa7d42c8e7d04a33c31b99867..88118aa42c6decdc923647bc7dcd241a03fbec40 100755 (executable)
@@ -162,7 +162,7 @@ sub get_differs ($$) {
        my @cmd = (@git, qw(diff-tree -z --no-renames));
        push @cmd, @$opts;
        push @cmd, "$_:" foreach $x, $y;
        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->(); }
     };
        my $diffs = cmdoutput @cmd;
        foreach (split /\0/, $diffs) { $fn->(); }
     };
@@ -770,9 +770,8 @@ sub update_head ($$$) {
 
 sub update_head_checkout ($$$) {
     my ($old, $new, $mrest) = @_;
 
 sub update_head_checkout ($$$) {
     my ($old, $new, $mrest) = @_;
-    my $symref = git_get_symref();
-    runcmd @git, qw(checkout), $new, qw(.);
     update_head $old, $new, $mrest;
     update_head $old, $new, $mrest;
+    runcmd @git, qw(reset --hard);
 }
 
 sub update_head_postlaunder ($$$) {
 }
 
 sub update_head_postlaunder ($$$) {
@@ -1020,13 +1019,39 @@ sub cmd_gbp2debrebase () {
     if ((git_cat_file "$upstream:debian")[0] ne 'missing') {
        fproblem "upstream ($upstream) contains debian/ directory";
     }
     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 {
 
     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 declare-upstream breakwater]'
+                             ];
+
+       # 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 () {
 }
 
 sub cmd_downstream_rebase_launder_v0 () {