chiark / gitweb /
catacomb-import-update: Improve import change listing algorithm
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 31 Dec 2019 12:55:19 +0000 (12:55 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 1 Jan 2020 23:48:14 +0000 (23:48 +0000)
Treat each file separately for the purposes of whether to say "Initial
import."  That now becomes an entry in the detailed change list.

We must change the variable @paths there to @lpaths, since the
surrounding code uses @paths for the complete set of paths, not just
the ones to pass to git-log.

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

index 9deeddf85d161fb3772454846826b91e1d688075..ad28b3f2e2d3684f882c7ccb88d8c4acee563d38 100755 (executable)
@@ -139,20 +139,21 @@ sub commit_changes () {
   }
 
   ## Now the detailed list of upstream commits.
-  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; }
-    }
+  $msg .= "\nDetailed list of changes:\n";
+  my @lpaths; my @roots;
+  for my $path (sort keys %DONOR_REV_MAP) {
+    my $rev = $DONOR_REV_MAP{$path};
+    if (defined $rev) { push @lpaths, $path; push @roots, $rev; }
+    else { $msg .= "  Initial import of $path.\n"; }
+  }
+  if (@roots) {
     chomp (my @revs = capturex @with_dir, $DONOR_DIR,
            "git", "rev-list", "--reverse",
-           "HEAD", "--not", @roots, "--", @paths);
+           "HEAD", "--not", @roots, "--", @lpaths);
 
     for my $rev (@revs) {
       my @affected = ();
-      for my $path (@paths) {
+      for my $path (@lpaths) {
        runx [0, 1], @with_dir, $DONOR_DIR,
          "git", "merge-base", "--is-ancestor",
          $DONOR_REV_MAP{$path}, $rev;
@@ -164,8 +165,6 @@ sub commit_changes () {
        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.