Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitd79d20d

Browse files
committed
Avoid taking a lock for reading
This isn't needed as git will replace this file atomicially,hence we always see a fully written file when reading.Only when writing we need to obtain a lock.
1 parent2141eae commitd79d20d

File tree

2 files changed

+3
-16
lines changed

2 files changed

+3
-16
lines changed

‎git/index/base.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -127,30 +127,17 @@ def __init__(self, repo: 'Repo', file_path: Union[PathLike, None] = None) -> Non
127127

128128
def_set_cache_(self,attr:str)->None:
129129
ifattr=="entries":
130-
# read the current index
131-
# try memory map for speed
132-
lfd=LockedFD(self._file_path)
133-
ok=False
134130
try:
135-
fd=lfd.open(write=False,stream=False)
136-
ok=True
131+
fd=os.open(self._file_path,os.O_RDONLY)
137132
exceptOSError:
138133
# in new repositories, there may be no index, which means we are empty
139134
self.entries:Dict[Tuple[PathLike,StageType],IndexEntry]= {}
140135
returnNone
141-
finally:
142-
ifnotok:
143-
lfd.rollback()
144136
# END exception handling
145137

146138
stream=file_contents_ro(fd,stream=True,allow_mmap=True)
147139

148-
try:
149-
self._deserialize(stream)
150-
finally:
151-
lfd.rollback()
152-
# The handles will be closed on destruction
153-
# END read from default index on demand
140+
self._deserialize(stream)
154141
else:
155142
super(IndexFile,self)._set_cache_(attr)
156143

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp