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

Commit530ab00

Browse files
FaromByron
authored andcommitted
read workdir from git.config as referenced in man 1 git-config
Edited-by: Florian Scherf <f.scherf@pengutronix.de>added the remaining feedback inhttps://github.com/gitpython-developers/GitPython/pull/801/files
1 parent926d45b commit530ab00

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

‎git/repo/base.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,21 @@ def __init__(self, path=None, odbt=GitCmdObjectDB, search_parent_directories=Fal
140140
# removed. It's just cleaner.
141141
ifis_git_dir(curpath):
142142
self.git_dir=curpath
143-
self._working_tree_dir=os.getenv('GIT_WORK_TREE',os.path.dirname(self.git_dir))
143+
# from man git-config : core.worktree
144+
# Set the path to the root of the working tree. If GIT_COMMON_DIR environment
145+
# variable is set, core.worktree is ignored and not used for determining the
146+
# root of working tree. This can be overridden by the GIT_WORK_TREE environment
147+
# variable. The value can be an absolute path or relative to the path to the .git
148+
# directory, which is either specified by GIT_DIR, or automatically discovered.
149+
# If GIT_DIR is specified but none of GIT_WORK_TREE and core.worktree is specified,
150+
# the current working directory is regarded as the top level of your working tree.
151+
self._working_tree_dir=os.path.dirname(self.git_dir)
152+
ifos.environ.get('GIT_COMMON_DIR')isNone:
153+
gitconf=self.config_reader("repository")
154+
ifgitconf.has_option('core','worktree'):
155+
self._working_tree_dir=gitconf.get('core','worktree')
156+
if'GIT_WORK_TREE'inos.environ:
157+
self._working_tree_dir=os.getenv('GIT_WORK_TREE')
144158
break
145159

146160
dotgit=osp.join(curpath,'.git')

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp