From 0b7ed19ab13a2bfa6278a0180768a9895aea9aff Mon Sep 17 00:00:00 2001 From: Mathias Preiner Date: Thu, 3 Dec 2020 22:32:17 -0800 Subject: [PATCH] update-copyright: Preserve file permissions. (#5597) When updating the copyright headers file permissions were not preserved. In some cases this results in losing the permission to execute scripts. This commit makes sure to preserve the file permissions for updated files. --- contrib/update-copyright.pl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/contrib/update-copyright.pl b/contrib/update-copyright.pl index 1f119d8e9..6a8482e76 100755 --- a/contrib/update-copyright.pl +++ b/contrib/update-copyright.pl @@ -257,6 +257,11 @@ sub handleFile { print $OUT $_; } close $OUT; + + # Preserve file permissions of $infile + my $perm = (stat($infile))[2] & 0777; + chmod $perm, $outfile; + rename($outfile, $infile) || die "can't rename working file \`$outfile' to \`$infile'"; } -- 2.30.2