git-p4: open temporary patch file for write only
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>
Joel Holdsworth committed
Dec 16, 2021 at 13:46 UTC
4cf67ae1b6c80eb8a63cc8dd752bd3951cffa104
1 file changed
+1
-1
git-p4.py
+1
-1
@@ -1754,7 +1754,7 @@ class P4Submit(Command, P4UserMap):
1754
# Attempt to zap the RCS keywords in a p4 controlled file matching the given regex
1755
(handle, outFileName) = tempfile.mkstemp(dir='.')
1756
try:
1757
- with os.fdopen(handle, "w+") as outFile, open(file, "r") as inFile:
1757
+ with os.fdopen(handle, "w") as outFile, open(file, "r") as inFile:
1758
for line in inFile.readlines():
1759
outFile.write(regexp.sub(r'$\1$', line))
1760
# Forcibly overwrite the original file