Skip to content

Improved way of listing URLs in remote #528

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 18 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
No need to create the lock file beforehand
  • Loading branch information
expobrain committed Sep 14, 2016
commit 6dfc870cffcfa7ca29e30301fff256e4e5b181f3
14 changes: 4 additions & 10 deletions git/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,20 +564,14 @@ def _obtain_lock_or_raise(self):

lock_file = self._lock_file_path()

# Create lock file
# Create file and lock
try:
open(lock_file, 'a').close()
except OSError as e:
# Silence error only if file exists
if e.errno != 17: # 17 -> File exists
raise

try:
fd = os.open(lock_file, os.O_WRONLY, 0)
flock(fd, LOCK_EX | LOCK_NB)
fd = os.open(lock_file, os.O_CREAT, 0)
except OSError as e:
raise IOError(str(e))

flock(fd, LOCK_EX | LOCK_NB)

self._file_descriptor = fd
self._owns_lock = True

Expand Down