]> git.ipfire.org Git - thirdparty/git.git/commitdiff
git-p4: open temporary patch file for write only
authorJoel Holdsworth <jholdsworth@nvidia.com>
Thu, 16 Dec 2021 13:46:18 +0000 (13:46 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 16 Dec 2021 22:06:36 +0000 (14:06 -0800)
The patchRCSKeywords method creates a temporary file in which to store
the patched output data. Previously this file was opened in "w+" mode
(write and read), but the code never reads the contents of the file
while open, so it only needs to be opened in "w" mode (write-only).

Signed-off-by: Joel Holdsworth <jholdsworth@nvidia.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-p4.py

index 509feac2d86d0613eb72e44f6be89f5e70a518bc..7845210e690e8adaeb556e28520c5e184f25dcc7 100755 (executable)
--- a/git-p4.py
+++ b/git-p4.py
@@ -1754,7 +1754,7 @@ class P4Submit(Command, P4UserMap):
         # Attempt to zap the RCS keywords in a p4 controlled file matching the given regex
         (handle, outFileName) = tempfile.mkstemp(dir='.')
         try:
-            with os.fdopen(handle, "w+") as outFile, open(file, "r") as inFile:
+            with os.fdopen(handle, "w") as outFile, open(file, "r") as inFile:
                 for line in inFile.readlines():
                     outFile.write(regexp.sub(r'$\1$', line))
             # Forcibly overwrite the original file