chiark / gitweb /
git-debrebase: test suite: test ff stitching
[dgit.git] / git-debrebase
index 93bf46b4f57b87cca420a26308b07f36c9ec8e26..a5329b6b117ffe27211282038edcc40aefd4e32d 100755 (executable)
@@ -1199,13 +1199,25 @@ sub cmd_stitch () {
     if (!$prev) {
        fail "No ffq-prev to stitch." unless $opt_noop_ok;
     }
-    fresh_workarea();
     my $old_head = get_head();
+    if (is_fast_fwd $old_head, $prev) {
+       my $differs = get_differs $old_head, $prev;
+       unless ($differs & ~D_PAT_ADD) {
+           # ffq-prev is ahead of us, and the only tree changes it has
+           # are possibly addition of things in debian/patches/.
+           # Just wind forwards rather than making a pointless pseudomerge.
+           update_head_checkout $old_head, $prev,
+               "debrebase: stitch (fast forward)";
+           runcmd @git, qw(update-ref -d), $ffq_prev; # should be atomic
+           return;
+       }
+    }
+    fresh_workarea();
     my $new_head = make_commit [ $old_head, $ffq_prev ], [
        'Declare fast forward / record previous work',
         "[git-debrebase pseudomerge: stitch$prose]",
     ];
-    my @upd_cmd = (@git, qw(update-ref --stdin));
+    my @upd_cmd = (@git, qw(update-ref --stdin -m), "debrebase: stitch");
     debugcmd '>|', @upd_cmd;
     open U, "|-", @upd_cmd or die $!;
     my $u = <<END;