chiark / gitweb /
git-debrebase: stitch: ff when possible
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 18 Feb 2018 13:20:07 +0000 (13:20 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 16 Jun 2018 15:06:59 +0000 (16:06 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
git-debrebase

index 93bf46b..c08af65 100755 (executable)
@@ -1199,8 +1199,20 @@ 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]",