Skip to content

Commit 4cf67ae

Browse files
jholgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9732e22 commit 4cf67ae

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

git-p4.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1754,7 +1754,7 @@ def patchRCSKeywords(self, file, regexp):
17541754
# Attempt to zap the RCS keywords in a p4 controlled file matching the given regex
17551755
(handle, outFileName) = tempfile.mkstemp(dir='.')
17561756
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:
17581758
for line in inFile.readlines():
17591759
outFile.write(regexp.sub(r'$\1$', line))
17601760
# Forcibly overwrite the original file

0 commit comments

Comments
 (0)