diff mbox

update-copyright.py: Retain file mode

Message ID 1466518497-22546-1-git-send-email-rep.dot.nop@gmail.com
State New
Headers show

Commit Message

Bernhard Reutner-Fischer June 21, 2016, 2:14 p.m. UTC
Hi!

Ok for trunk?

thanks,

contrib/ChangeLog

2016-06-21  Bernhard Reutner-Fischer  <aldot@gcc.gnu.org>

	* update-copyright.py (Copyright.process_file): Retain original
	file mode.
---
 contrib/update-copyright.py | 3 +++
 1 file changed, 3 insertions(+)

Comments

Jeff Law June 21, 2016, 3 p.m. UTC | #1
On 06/21/2016 08:14 AM, Bernhard Reutner-Fischer wrote:
> Hi!
>
> Ok for trunk?
>
> thanks,
>
> contrib/ChangeLog
>
> 2016-06-21  Bernhard Reutner-Fischer  <aldot@gcc.gnu.org>
>
> 	* update-copyright.py (Copyright.process_file): Retain original
> 	file mode.
OK.
jeff
Bernhard Reutner-Fischer Jan. 30, 2017, 2:34 p.m. UTC | #2
On Tue, Jun 21, 2016 at 09:00:58AM -0600, Jeff Law wrote:
> On 06/21/2016 08:14 AM, Bernhard Reutner-Fischer wrote:
> > Hi!
> > 
> > Ok for trunk?
> > 
> > thanks,
> > 
> > contrib/ChangeLog
> > 
> > 2016-06-21  Bernhard Reutner-Fischer  <aldot@gcc.gnu.org>
> > 
> > 	* update-copyright.py (Copyright.process_file): Retain original
> > 	file mode.
> OK.
> jeff

Thanks Jeff. Now committed as r245028.
diff mbox

Patch

diff --git a/contrib/update-copyright.py b/contrib/update-copyright.py
index ebefa46..04afd18 100755
--- a/contrib/update-copyright.py
+++ b/contrib/update-copyright.py
@@ -393,8 +393,10 @@  class Copyright:
         lines = []
         changed = False
         line_filter = filter.get_line_filter (dir, filename)
+        mode = None
         with open (pathname, 'r') as file:
             prev = None
+            mode = os.fstat (file.fileno()).st_mode
             for line in file:
                 while line:
                     next_line = None
@@ -421,6 +423,7 @@  class Copyright:
             with open (tmp_pathname, 'w') as file:
                 for line in lines:
                     file.write (line)
+                os.fchmod (file.fileno(), mode)
             if self.use_quilt:
                 subprocess.call (['quilt', 'add', pathname])
             os.rename (tmp_pathname, pathname)