Skip to content

Respect _common_dir when finding repository config file #796

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Respect _common_dir when finding repository config file
Among other things, remotes are now correctly identified when in a
separate worktree.
  • Loading branch information
delego-wlritchi committed Sep 14, 2018
commit 359521cbce850a8045e04c1695672998a35a8e71
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -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.
2 changes: 1 addition & 1 deletion git/repo/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ def _get_config_path(self, config_level):
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)

Expand Down
5 changes: 5 additions & 0 deletions git/test/test_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -974,6 +974,11 @@ def test_git_work_tree_dotgit(self, rw_dir):
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
Expand Down