Skip to content

Commit 89df641

Browse files
delego-wlritchiByron
authored andcommitted
Respect _common_dir when finding repository config file
Among other things, remotes are now correctly identified when in a separate worktree.
1 parent a8591a0 commit 89df641

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

AUTHORS

+1
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,6 @@ Contributors are:
2727
-Charles Bouchard-Légaré <cblegare.atl _at_ ntis.ca>
2828
-Yaroslav Halchenko <debian _at_ onerussian.com>
2929
-Tim Swast <swast _at_ google.com>
30+
-William Luc Ritchie
3031

3132
Portions derived from other open source works and are clearly marked.

git/repo/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ def _get_config_path(self, config_level):
416416
elif config_level == "global":
417417
return osp.normpath(osp.expanduser("~/.gitconfig"))
418418
elif config_level == "repository":
419-
return osp.normpath(osp.join(self.git_dir, "config"))
419+
return osp.normpath(osp.join(self._common_dir or self.git_dir, "config"))
420420

421421
raise ValueError("Invalid configuration level: %r" % config_level)
422422

git/test/test_repo.py

+5
Original file line numberDiff line numberDiff line change
@@ -974,6 +974,11 @@ def test_git_work_tree_dotgit(self, rw_dir):
974974
commit = repo.head.commit
975975
self.assertIsInstance(commit, Object)
976976

977+
# this ensures we can read the remotes, which confirms we're reading
978+
# the config correctly.
979+
origin = repo.remotes.origin
980+
self.assertIsInstance(origin, Remote)
981+
977982
self.assertIsInstance(repo.heads['aaaaaaaa'], Head)
978983

979984
@with_rw_directory

0 commit comments

Comments
 (0)