diff options
author | Jeremy Retailleau <jeremy.retailleau@gmail.com> | 2020-09-03 11:24:10 -0700 |
---|---|---|
committer | Jeremy Retailleau <jeremy.retailleau@gmail.com> | 2020-09-03 11:24:10 -0700 |
commit | 5b88532a5346a9a7e8f0e45fec14632a9bfe2c89 (patch) | |
tree | 8b897d6ef521ce66cd346456ce87ab5315cf1c84 /git | |
parent | 3787f622e59c2fecfa47efc114c409f51a27bbe7 (diff) | |
download | gitpython-5b88532a5346a9a7e8f0e45fec14632a9bfe2c89.tar.gz |
Ensure that detached HEAD does not raise when comparing branch name.
Diffstat (limited to 'git')
-rw-r--r-- | git/config.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/git/config.py b/git/config.py index b49f0790..9f09efe2 100644 --- a/git/config.py +++ b/git/config.py @@ -493,7 +493,13 @@ class GitConfigParser(with_metaclass(MetaParserBuilder, cp.RawConfigParser, obje paths += self.items(section) elif keyword == "onbranch": - if fnmatch.fnmatchcase(self._repo.active_branch.name, value): + try: + branch_name = self._repo.active_branch.name + except TypeError: + # Ignore section if active branch cannot be retrieved. + continue + + if fnmatch.fnmatchcase(branch_name, value): paths += self.items(section) return paths |