Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6dfc870

Browse filesBrowse files
committed
No need to create the lock file beforehand
1 parent 547e6f0 commit 6dfc870
Copy full SHA for 6dfc870

1 file changed

+4-10Lines changed: 4 additions & 10 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎git/util.py‎

Copy file name to clipboardExpand all lines: git/util.py
+4-10Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -564,20 +564,14 @@ def _obtain_lock_or_raise(self):
564564

565565
lock_file = self._lock_file_path()
566566

567-
# Create lock file
567+
# Create file and lock
568568
try:
569-
open(lock_file, 'a').close()
570-
except OSError as e:
571-
# Silence error only if file exists
572-
if e.errno != 17: # 17 -> File exists
573-
raise
574-
575-
try:
576-
fd = os.open(lock_file, os.O_WRONLY, 0)
577-
flock(fd, LOCK_EX | LOCK_NB)
569+
fd = os.open(lock_file, os.O_CREAT, 0)
578570
except OSError as e:
579571
raise IOError(str(e))
580572

573+
flock(fd, LOCK_EX | LOCK_NB)
574+
581575
self._file_descriptor = fd
582576
self._owns_lock = True
583577

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.