chiark / gitweb /
catacomb-import-update: commit_changes: Introduce $idir
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 31 Dec 2019 17:08:52 +0000 (17:08 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 2 Jan 2020 00:30:56 +0000 (00:30 +0000)
This replaces all references to $DONOR_IMPORT_DIR.  This makes the
code shorter and will make the next commit less noisy.

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

index 9834f3c5167f330c237bbe145feadcc34329a2ef..fffbe7a001e791c339fa81eaf5fd717c129af91e 100755 (executable)
@@ -114,23 +114,23 @@ sub commit_changes () {
 
   return if $DOCONVERT;
 
-  my $dir = $DONOR_IMPORT_DIR;
-  runx 'rm', '-rf', $dir;
-  runx 'mkdir', $dir;
+  my $idir = $DONOR_IMPORT_DIR;
+  runx 'rm', '-rf', $idir;
+  runx 'mkdir', $idir;
 
   my @paths = sort keys %DONOR_REV_MAP;
-  runx 'rsync', '-Rc', (map { "$DONOR_DIR/./$_" } @paths), $DONOR_IMPORT_DIR;
+  runx 'rsync', '-Rc', (map { "$DONOR_DIR/./$_" } @paths), $idir;
 
-  my $mff = "$DONOR_IMPORT_DIR/$MAKEFILE_FRAGMENT";
+  my $mff = "$idir/$MAKEFILE_FRAGMENT";
   write_makefile_fragment("$mff.new");
   rename "$mff.new", "$mff";
   
   ## Stage updated files for commit.
-  runx "git", "add", "-A", $dir;
+  runx "git", "add", "-A", $idir;
 
   ## Inspect the changed files.  Notice whether we've actually changed or
   ## added files.
-  chomp (my @diff = capturex "git", "diff-index", "--cached", "HEAD", $dir);
+  chomp (my @diff = capturex "git", "diff-index", "--cached", "HEAD", $idir);
   my %changed = ();
   my %new = ();
   for my $line (@diff) {
@@ -142,7 +142,7 @@ sub commit_changes () {
       or die "incomprehensible git-diff line `$line'";
     my $path = ($3 eq "C" or $3 eq "R") ? $5 : $4;
     my $old = $1;
-    next unless $path =~ s{^$dir/}{};
+    next unless $path =~ s{^$idir/}{};
     $changed{$path} = 1; $new{$path} = ($old !~ /[^0]/);
   }
 
@@ -195,7 +195,7 @@ sub commit_changes () {
 
   ## Commit everything.
   runx "git", "commit", "--edit", "--message", $msg,
-      map { "$dir/$_" } keys %changed;
+      map { "$idir/$_" } keys %changed;
 }
 
 ###--------------------------------------------------------------------------