Skip to content

Commit a728b0a

Browse files
committed
fixes from #1202
1 parent 5232c89 commit a728b0a

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

git/repo/base.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -268,13 +268,14 @@ def __hash__(self) -> int:
268268

269269
# Description property
270270
def _get_description(self) -> str:
271-
filename = osp.join(self.git_dir, 'description') if self.git_dir else ""
271+
if self.git_dir:
272+
filename = osp.join(self.git_dir, 'description')
272273
with open(filename, 'rb') as fp:
273274
return fp.read().rstrip().decode(defenc)
274275

275276
def _set_description(self, descr: str) -> None:
276-
277-
filename = osp.join(self.git_dir, 'description') if self.git_dir else ""
277+
if self.git_dir:
278+
filename = osp.join(self.git_dir, 'description')
278279
with open(filename, 'wb') as fp:
279280
fp.write((descr + '\n').encode(defenc))
280281

@@ -460,12 +461,11 @@ def _get_config_path(self, config_level: Lit_config_levels) -> str:
460461
elif config_level == "global":
461462
return osp.normpath(osp.expanduser("~/.gitconfig"))
462463
elif config_level == "repository":
463-
if self._common_dir:
464-
return osp.normpath(osp.join(self._common_dir, "config"))
465-
elif self.git_dir:
466-
return osp.normpath(osp.join(self.git_dir, "config"))
467-
else:
464+
repo_dir = self._common_dir or self.git_dir
465+
if not repo_dir:
468466
raise NotADirectoryError
467+
else:
468+
return osp.normpath(osp.join(repo_dir, "config"))
469469

470470
raise ValueError("Invalid configuration level: %r" % config_level)
471471

@@ -611,11 +611,13 @@ def is_ancestor(self, ancestor_rev: 'Commit', rev: 'Commit') -> bool:
611611
return True
612612

613613
def _get_daemon_export(self) -> bool:
614-
filename = osp.join(self.git_dir, self.DAEMON_EXPORT_FILE) if self.git_dir else ""
614+
if self.git_dir:
615+
filename = osp.join(self.git_dir, self.DAEMON_EXPORT_FILE)
615616
return osp.exists(filename)
616617

617618
def _set_daemon_export(self, value: object) -> None:
618-
filename = osp.join(self.git_dir, self.DAEMON_EXPORT_FILE) if self.git_dir else ""
619+
if self.git_dir:
620+
filename = osp.join(self.git_dir, self.DAEMON_EXPORT_FILE)
619621
fileexists = osp.exists(filename)
620622
if value and not fileexists:
621623
touch(filename)
@@ -631,7 +633,8 @@ def _get_alternates(self) -> List[str]:
631633
"""The list of alternates for this repo from which objects can be retrieved
632634
633635
:return: list of strings being pathnames of alternates"""
634-
alternates_path = osp.join(self.git_dir, 'objects', 'info', 'alternates') if self.git_dir else ""
636+
if self.git_dir:
637+
alternates_path = osp.join(self.git_dir, 'objects', 'info', 'alternates')
635638

636639
if osp.exists(alternates_path):
637640
with open(alternates_path, 'rb') as f:
@@ -1134,7 +1137,8 @@ def currently_rebasing_on(self) -> Union['SymbolicReference', Commit, 'TagObject
11341137
11351138
None if we are not currently rebasing.
11361139
"""
1137-
rebase_head_file = osp.join(self.git_dir, "REBASE_HEAD") if self.git_dir else ""
1140+
if self.git_dir:
1141+
rebase_head_file = osp.join(self.git_dir, "REBASE_HEAD")
11381142
if not osp.isfile(rebase_head_file):
11391143
return None
11401144
return self.commit(open(rebase_head_file, "rt").readline().strip())

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