^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) #!/usr/bin/env perl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) # SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) # Treewide grep for references to files under Documentation, and report
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) # non-existing files in stderr.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) use warnings;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) use strict;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) use Getopt::Long qw(:config no_auto_abbrev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) # NOTE: only add things here when the file was gone, but the text wants
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) # to mention a past documentation file, for example, to give credits for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) # the original work.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) my %false_positives = (
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) "Documentation/scsi/scsi_mid_low_api.rst" => "Documentation/Configure.help",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) "drivers/vhost/vhost.c" => "Documentation/virtual/lguest/lguest.c",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) my $scriptname = $0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) $scriptname =~ s,.*/([^/]+/),$1,;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) # Parse arguments
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) my $help = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) my $fix = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) my $warn = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) if (! -d ".git") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) printf "Warning: can't check if file exists, as this is not a git tree\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) exit 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) GetOptions(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 'fix' => \$fix,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 'warn' => \$warn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 'h|help|usage' => \$help,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) if ($help != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) print "$scriptname [--help] [--fix]\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) exit -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) # Step 1: find broken references
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) print "Finding broken references. This may take a while... " if ($fix);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) my %broken_ref;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) my $doc_fix = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) open IN, "git grep ':doc:\`' Documentation/|"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) or die "Failed to run git grep";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) while (<IN>) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) next if (!m,^([^:]+):.*\:doc\:\`([^\`]+)\`,);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) next if (m,sphinx/,);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) my $file = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) my $d = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) my $doc_ref = $2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) my $f = $doc_ref;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) $d =~ s,(.*/).*,$1,;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) $f =~ s,.*\<([^\>]+)\>,$1,;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) if ($f =~ m,^/,) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) $f = "$f.rst";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) $f =~ s,^/,Documentation/,;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) $f = "$d$f.rst";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) next if (grep -e, glob("$f"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) if ($fix && !$doc_fix) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) print STDERR "\nWARNING: Currently, can't fix broken :doc:`` fields\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) $doc_fix++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) print STDERR "$file: :doc:`$doc_ref`\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) close IN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) open IN, "git grep 'Documentation/'|"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) or die "Failed to run git grep";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) while (<IN>) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) next if (!m/^([^:]+):(.*)/);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) my $f = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) my $ln = $2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) # On linux-next, discard the Next/ directory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) next if ($f =~ m,^Next/,);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) # Makefiles and scripts contain nasty expressions to parse docs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) next if ($f =~ m/Makefile/ || $f =~ m/\.sh$/);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) # Skip this script
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) next if ($f eq $scriptname);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) # Ignore the dir where documentation will be built
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) next if ($ln =~ m,\b(\S*)Documentation/output,);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) if ($ln =~ m,\b(\S*)(Documentation/[A-Za-z0-9\_\.\,\~/\*\[\]\?+-]*)(.*),) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) my $prefix = $1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) my $ref = $2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) my $base = $2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) my $extra = $3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) # some file references are like:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) # /usr/src/linux/Documentation/DMA-{API,mapping}.txt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) # For now, ignore them
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) next if ($extra =~ m/^{/);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) # Remove footnotes at the end like:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) # Documentation/devicetree/dt-object-internal.txt[1]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) $ref =~ s/(txt|rst)\[\d+]$/$1/;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) # Remove ending ']' without any '['
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) $ref =~ s/\].*// if (!($ref =~ m/\[/));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) # Remove puntuation marks at the end
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) $ref =~ s/[\,\.]+$//;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) my $fulref = "$prefix$ref";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) $fulref =~ s/^(\<file|ref)://;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) $fulref =~ s/^[\'\`]+//;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) $fulref =~ s,^\$\(.*\)/,,;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) $base =~ s,.*/,,;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) # Remove URL false-positives
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) next if ($fulref =~ m/^http/);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) # Remove sched-pelt false-positive
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) next if ($fulref =~ m,^Documentation/scheduler/sched-pelt$,);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) # Discard some build examples from Documentation/target/tcm_mod_builder.rst
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) next if ($fulref =~ m,mnt/sdb/lio-core-2.6.git/Documentation/target,);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) # Check if exists, evaluating wildcards
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) next if (grep -e, glob("$ref $fulref"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) # Accept relative Documentation patches for tools/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) if ($f =~ m/tools/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) my $path = $f;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) $path =~ s,(.*)/.*,$1,;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) next if (grep -e, glob("$path/$ref $path/../$ref $path/$fulref"));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) # Discard known false-positives
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) if (defined($false_positives{$f})) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) next if ($false_positives{$f} eq $fulref);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) if ($fix) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) if (!($ref =~ m/(scripts|Kconfig|Kbuild)/)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) $broken_ref{$ref}++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) } elsif ($warn) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) print STDERR "Warning: $f references a file that doesn't exist: $fulref\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) print STDERR "$f: $fulref\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) close IN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) exit 0 if (!$fix);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) # Step 2: Seek for file name alternatives
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) print "Auto-fixing broken references. Please double-check the results\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) foreach my $ref (keys %broken_ref) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) my $new =$ref;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) my $basedir = ".";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) # On translations, only seek inside the translations directory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) $basedir = $1 if ($ref =~ m,(Documentation/translations/[^/]+),);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) # get just the basename
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) $new =~ s,.*/,,;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) my $f="";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) # usual reason for breakage: DT file moved around
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) if ($ref =~ /devicetree/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) # usual reason for breakage: DT file renamed to .yaml
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) if (!$f) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) my $new_ref = $ref;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) $new_ref =~ s/\.txt$/.yaml/;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) $f=$new_ref if (-f $new_ref);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) if (!$f) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) my $search = $new;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) $search =~ s,^.*/,,;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) $f = qx(find Documentation/devicetree/ -iname "*$search*") if ($search);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) if (!$f) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) # Manufacturer name may have changed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) $search =~ s/^.*,//;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) $f = qx(find Documentation/devicetree/ -iname "*$search*") if ($search);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) # usual reason for breakage: file renamed to .rst
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) if (!$f) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) $new =~ s/\.txt$/.rst/;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) $f=qx(find $basedir -iname $new) if ($new);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) # usual reason for breakage: use dash or underline
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) if (!$f) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) $new =~ s/[-_]/[-_]/g;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) $f=qx(find $basedir -iname $new) if ($new);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) # Wild guess: seek for the same name on another place
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) if (!$f) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) $f = qx(find $basedir -iname $new) if ($new);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) my @find = split /\s+/, $f;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) if (!$f) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) print STDERR "ERROR: Didn't find a replacement for $ref\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) } elsif (scalar(@find) > 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) print STDERR "WARNING: Won't auto-replace, as found multiple files close to $ref:\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) foreach my $j (@find) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) $j =~ s,^./,,;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) print STDERR " $j\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) $f = $find[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) $f =~ s,^./,,;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) print "INFO: Replacing $ref to $f\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) foreach my $j (qx(git grep -l $ref)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) qx(sed "s\@$ref\@$f\@g" -i $j);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) }