From c0bf02b4c22a720b251aaeea4e716bda658b32da Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Thu, 20 Aug 2015 13:17:26 -0700 Subject: [PATCH] zanitizer: Support renaming files (imported from commit 6a094177d652a267b53aa5042110b39fcbf21b42) --- tools/zanitizer | 14 ++++++++++---- tools/zanitizer_config.pm.sample | 6 +++++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/tools/zanitizer b/tools/zanitizer index b1e6d47855..9877da9ead 100755 --- a/tools/zanitizer +++ b/tools/zanitizer @@ -39,6 +39,7 @@ my %commit_tree = (); my %scrubbed_blob = (); my %scrubbed_file = (); my %deleted_file = (); +my %renamed_file = (); open FAST_EXPORT, '<', $fast_export_file or die "cannot open $fast_export_file: $!"; $_ = ; @@ -115,12 +116,15 @@ while (defined $_) { last; } elsif (/^D (?'file'.*)\n$/s) { $_ = $+{file}; - push @delete, {%+} if keep_file; + scrub_filename; + push @delete, {%+, file => $_} if defined $_; } elsif (/^M (?'mode'\d+) (?'mark'\S+) (?'file'.*)\n$/s) { $_ = $+{file}; - if (keep_file) { - $scrubbed_file{$+{file}} = 1 if exists $scrubbed_blob{$+{mark}}; - push @modify, {%+}; + scrub_filename; + if (defined $_) { + $renamed_file{$+{file}} = $_ if $_ ne $+{file}; + $scrubbed_file{$_} = 1 if exists $scrubbed_blob{$+{mark}}; + push @modify, {%+, file => $_}; } else { $deleted_file{$+{file}} = 1; } @@ -168,5 +172,7 @@ close FAST_EXPORT; print STDERR "Deleted files:\n"; print STDERR " $_\n" for sort keys %deleted_file; +print STDERR "Renamed files:\n"; +print STDERR " $_ => $renamed_file{$_}\n" for sort keys %renamed_file; print STDERR "Scrubbed files:\n"; print STDERR " $_\n" for sort keys %scrubbed_file; diff --git a/tools/zanitizer_config.pm.sample b/tools/zanitizer_config.pm.sample index a5b0f70de5..4f9dbc6c8b 100644 --- a/tools/zanitizer_config.pm.sample +++ b/tools/zanitizer_config.pm.sample @@ -9,7 +9,11 @@ sub scrub_text { } sub keep_file { - !m%^secret-directory/% && !m%settings\.ini$% + if (m%^secret-directory/% || m%settings\.ini$%) { + undef $_; + } else { + s/bruce/batman/g; + } } 1;