From: Ian Jackson Date: Tue, 31 Dec 2019 17:08:52 +0000 (+0000) Subject: catacomb-import-update: commit_changes: Introduce $idir X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=751cb6b0fb7b61619916dd616d25b97477ff3d33;p=secnet.git catacomb-import-update: commit_changes: Introduce $idir 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 --- diff --git a/catacomb-import-update b/catacomb-import-update index 9834f3c..fffbe7a 100755 --- a/catacomb-import-update +++ b/catacomb-import-update @@ -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; } ###--------------------------------------------------------------------------