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

Commitd5cc590

Browse files
author
Sebastian Thiel
committed
Fix performance regression, seegitpython-developers#906
Revert "use git rev-parse to look for config file"This reverts commit0b6b90f.Fixgitpython-developers#906Reopengitpython-developers#719
1 parent5fa99bf commitd5cc590

File tree

2 files changed

+18
-41
lines changed

2 files changed

+18
-41
lines changed

‎git/repo/base.py

Lines changed: 16 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class Repo(object):
6767
'git_dir' is the .git repository directory, which is always set."""
6868
DAEMON_EXPORT_FILE='git-daemon-export-ok'
6969

70-
_git=None# Must exist, or __del__ will fail in case we raise on `__init__()`
70+
git=None# Must exist, or __del__ will fail in case we raise on `__init__()`
7171
working_dir=None
7272
_working_tree_dir=None
7373
git_dir=None
@@ -203,42 +203,14 @@ def __init__(self, path=None, odbt=GitCmdObjectDB, search_parent_directories=Fal
203203
# END working dir handling
204204

205205
self.working_dir=self._working_tree_dirorself.common_dir
206+
self.git=self.GitCommandWrapperType(self.working_dir)
206207

207208
# special handling, in special times
208209
args= [osp.join(self.common_dir,'objects')]
209210
ifissubclass(odbt,GitCmdObjectDB):
210211
args.append(self.git)
211212
self.odb=odbt(*args)
212213

213-
def_get_git(self):
214-
working_dir=self._working_tree_dirorself.common_dir
215-
ifself._git:
216-
ifself._git._working_dir!=expand_path(working_dir):
217-
self.close()
218-
self._git=None
219-
220-
ifnotself._git:
221-
self._git=self.GitCommandWrapperType(working_dir)
222-
returnself._git
223-
224-
def_del_git(self):
225-
ifself._git:
226-
self._git.clear_cache()
227-
self._git=None
228-
# Tempfiles objects on Windows are holding references to
229-
# open files until they are collected by the garbage
230-
# collector, thus preventing deletion.
231-
# TODO: Find these references and ensure they are closed
232-
# and deleted synchronously rather than forcing a gc
233-
# collection.
234-
ifis_win:
235-
gc.collect()
236-
gitdb.util.mman.collect()
237-
ifis_win:
238-
gc.collect()
239-
240-
git=property(fget=_get_git,fdel=_del_git)
241-
242214
def__enter__(self):
243215
returnself
244216

@@ -252,7 +224,19 @@ def __del__(self):
252224
pass
253225

254226
defclose(self):
255-
delself.git
227+
ifself.git:
228+
self.git.clear_cache()
229+
# Tempfiles objects on Windows are holding references to
230+
# open files until they are collected by the garbage
231+
# collector, thus preventing deletion.
232+
# TODO: Find these references and ensure they are closed
233+
# and deleted synchronously rather than forcing a gc
234+
# collection.
235+
ifis_win:
236+
gc.collect()
237+
gitdb.util.mman.collect()
238+
ifis_win:
239+
gc.collect()
256240

257241
def__eq__(self,rhs):
258242
ifisinstance(rhs,Repo):
@@ -448,15 +432,7 @@ def _get_config_path(self, config_level):
448432
elifconfig_level=="global":
449433
returnosp.normpath(osp.expanduser("~/.gitconfig"))
450434
elifconfig_level=="repository":
451-
try:
452-
config_path=self.git.rev_parse("config",git_path=True)
453-
exceptGitCommandError:
454-
returnosp.normpath(osp.join(self._common_dirorself.git_dir,"config"))
455-
else:
456-
ifself.git._working_dir:
457-
returnosp.normpath(osp.join(self.git._working_dir,config_path))
458-
else:
459-
returnconfig_path
435+
returnosp.normpath(osp.join(self._common_dirorself.git_dir,"config"))
460436

461437
raiseValueError("Invalid configuration level: %r"%config_level)
462438

‎git/test/lib/helper.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,8 @@ def setUpClass(cls):
366366

367367
@classmethod
368368
deftearDownClass(cls):
369-
delcls.rorepo.git
369+
cls.rorepo.git.clear_cache()
370+
cls.rorepo.git=None
370371

371372
def_make_file(self,rela_path,data,repo=None):
372373
"""

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp