summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuc Ritchie <wlritchi@delegopayments.com>2018-09-14 13:10:37 -0400
committerSebastian Thiel <byronimo@gmail.com>2018-10-13 13:41:13 +0200
commit89df64132ccd76568ade04b5cf4e68cb67f0c5c0 (patch)
tree06d7d78850d51f7362bda6eb6f239f7c93ba349e
parenta8591a094a768d73e6efb5a698f74d354c989291 (diff)
downloadgitpython-89df64132ccd76568ade04b5cf4e68cb67f0c5c0.tar.gz
Respect _common_dir when finding repository config file
Among other things, remotes are now correctly identified when in a separate worktree.
-rw-r--r--AUTHORS1
-rw-r--r--git/repo/base.py2
-rw-r--r--git/test/test_repo.py5
3 files changed, 7 insertions, 1 deletions
diff --git a/AUTHORS b/AUTHORS
index 9c3a52c0..2e006ba2 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -27,5 +27,6 @@ Contributors are:
-Charles Bouchard-Légaré <cblegare.atl _at_ ntis.ca>
-Yaroslav Halchenko <debian _at_ onerussian.com>
-Tim Swast <swast _at_ google.com>
+-William Luc Ritchie
Portions derived from other open source works and are clearly marked.
diff --git a/git/repo/base.py b/git/repo/base.py
index 023582b5..125ab802 100644
--- a/git/repo/base.py
+++ b/git/repo/base.py
@@ -416,7 +416,7 @@ class Repo(object):
elif config_level == "global":
return osp.normpath(osp.expanduser("~/.gitconfig"))
elif config_level == "repository":
- return osp.normpath(osp.join(self.git_dir, "config"))
+ return osp.normpath(osp.join(self._common_dir or self.git_dir, "config"))
raise ValueError("Invalid configuration level: %r" % config_level)
diff --git a/git/test/test_repo.py b/git/test/test_repo.py
index e65ead89..7fc49f3b 100644
--- a/git/test/test_repo.py
+++ b/git/test/test_repo.py
@@ -974,6 +974,11 @@ class TestRepo(TestBase):
commit = repo.head.commit
self.assertIsInstance(commit, Object)
+ # this ensures we can read the remotes, which confirms we're reading
+ # the config correctly.
+ origin = repo.remotes.origin
+ self.assertIsInstance(origin, Remote)
+
self.assertIsInstance(repo.heads['aaaaaaaa'], Head)
@with_rw_directory