chiark / gitweb /
git-debrebase: Actually avoid read-tree in walk when not rewriting
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 19 Aug 2018 15:44:56 +0000 (16:44 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 19 Aug 2018 16:46:00 +0000 (17:46 +0100)
See
   git-debrebase: Prep for avoid read-tree in walk when not rewriting
for the motivation.

Here we try to check that the commit we would make, if we were
actually calling read-tree, write-tree and hash-object, would be
identical to the one we are reusing.

In particular, we check that the upstream files, and the debian/
directory, have the contents we would feed to read-tree.  And we check
that the parent list is the same.

With these checks this new algorithm is, I think, safe enough to just
use always.   So set $opt_careful to 0.  We will abolish this
variable in a moment.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
debian/changelog
git-debrebase

index f678131df99851d293480e5a1b9c7d5d28ce71cd..58b934ece8be36c089ac140545cd564261c27c0c 100644 (file)
@@ -7,6 +7,7 @@ dgit (6.7~) unstable; urgency=medium
   * git-debrebase: scrap works properly when it does only rebase --abort.
   * dgit(1): Encourage --overwrite rather than --overwrite=version.
   * test suite: unset GIT_EDITOR, so it works if user has that set.
+  * git-debrebase: Improve laundry performance.  Closes:#905995.
 
  --
 
index d04f2a3af54882d2f256ea82341349525e54c5e9..c240d88b44ca7c6f7d8fe52ccfec5f8bd9982370 100755 (executable)
@@ -53,7 +53,7 @@ END
 our ($opt_force, $opt_careful, $opt_noop_ok, @opt_anchors);
 our ($opt_defaultcmd_interactive);
 
-$opt_careful = 1;
+$opt_careful = 0;
 
 our $us = qw(git-debrebase);
 
@@ -1612,6 +1612,18 @@ sub walk ($;$$$) {
                $build = $newcommit;
            } else {
                $build = $cl->{CommitId};
+               trees_diff_walk "$want_upstream:", "$build:", sub {
+                   my ($n) = @_;
+                   no warnings qw(exiting);
+                   next if $n eq 'debian/';
+                   confess "mismatch @_ ?";
+               };
+               trees_diff_walk "$want_debian:debian", "$build:debian", sub {
+                   confess "mismatch @_ ?";
+               };
+               my @old_parents = map { $_->{CommitId} } @{ $cl->{Parents} };
+               confess "mismatch @parents != @old_parents ?"
+                   unless "@parents" eq "@old_parents";
            }
             if (grep { $method eq $_ } qw(DgitImportUpstreamUpdate)) {
                 $last_anchor = $cur;