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

Commit63104d6

Browse files
committed
Avoid taking a lock for reading (#1338)
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 commit63104d6

File tree

2 files changed

+3
-13
lines changed

2 files changed

+3
-13
lines changed

‎git/index/base.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -129,28 +129,18 @@ def _set_cache_(self, attr: str) -> None:
129129
ifattr=="entries":
130130
# read the current index
131131
# try memory map for speed
132-
lfd=LockedFD(self._file_path)
133132
ok=False
134133
try:
135-
fd=lfd.open(write=False,stream=False)
136-
ok=True
134+
fd=os.open(self._file_path,os.O_RDONLY)
137135
exceptOSError:
138136
# in new repositories, there may be no index, which means we are empty
139137
self.entries:Dict[Tuple[PathLike,StageType],IndexEntry]= {}
140138
returnNone
141-
finally:
142-
ifnotok:
143-
lfd.rollback()
144139
# END exception handling
145140

146141
stream=file_contents_ro(fd,stream=True,allow_mmap=True)
147142

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
143+
self._deserialize(stream)
154144
else:
155145
super(IndexFile,self)._set_cache_(attr)
156146

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp