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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 5 additions & 0 deletions
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy