chiark / gitweb /
import-catacomb-crypto: Do not go mad on initial import
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 31 Dec 2019 10:44:58 +0000 (10:44 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 1 Jan 2020 23:48:14 +0000 (23:48 +0000)
I think the branch I received must have had its initial import done
with a different version of this script.  When I tried it, I got
"argument list too long" because the whole history of every relevant
file had been included in the commit message.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
import-catacomb-crypto

index c6a89ef5ef015cb47070bd5243a8df7878c8f574..98a09638c6f7c816221078cc6d1bf6dfef14dbce 100755 (executable)
@@ -148,29 +148,33 @@ sub commit_changes () {
   }
 
   ## Now the detailed list of upstream commits.
-  $msg .= "\nDetailed list of changes:\n";
-  my @paths; my @roots;
-  for my $path (keys %DONOR_REV_MAP) {
-    my $rev = $DONOR_REV_MAP{$path};
-    if (defined $rev) { push @paths, $path; push @roots, $rev; }
-  }
-  chomp (my @revs = capturex @with_dir, $DONOR_DIR,
-         "git", "rev-list", "--reverse",
-         "HEAD", "--not", @roots, "--", @paths);
-
-  for my $rev (@revs) {
-    my @affected = ();
-    for my $path (@paths) {
-      runx [0, 1], @with_dir, $DONOR_DIR,
-       "git", "merge-base", "--is-ancestor",
-       $DONOR_REV_MAP{$path}, $rev;
-      push @affected, $path if !$EXITVAL;
+  if (grep { defined } values %DONOR_REV_MAP) {
+    $msg .= "\nDetailed list of changes:\n";
+    my @paths; my @roots;
+    for my $path (keys %DONOR_REV_MAP) {
+      my $rev = $DONOR_REV_MAP{$path};
+      if (defined $rev) { push @paths, $path; push @roots, $rev; }
+    }
+    chomp (my @revs = capturex @with_dir, $DONOR_DIR,
+           "git", "rev-list", "--reverse",
+           "HEAD", "--not", @roots, "--", @paths);
+
+    for my $rev (@revs) {
+      my @affected = ();
+      for my $path (@paths) {
+       runx [0, 1], @with_dir, $DONOR_DIR,
+         "git", "merge-base", "--is-ancestor",
+         $DONOR_REV_MAP{$path}, $rev;
+       push @affected, $path if !$EXITVAL;
+      }
+      $msg .= "\n" . join "",
+       grep { s/\s+$/\n/ }
+       map { "    " . $_ }
+       capturex @with_dir, $DONOR_DIR,
+       "git", "show", "--stat", $rev, "--", @affected;
     }
-    $msg .= "\n" . join "",
-      grep { s/\s+$/\n/ }
-      map { "    " . $_ }
-      capturex @with_dir, $DONOR_DIR,
-      "git", "show", "--stat", $rev, "--", @affected;
+  } else {
+    $msg .= "\nInitial import.\n";
   }
 
   ## The trailer, so that we can see where we left off.