Skip to content

Commit

Permalink
Handle GitCommandError exception
Browse files Browse the repository at this point in the history
  • Loading branch information
douglaslassance committed Mar 20, 2022
1 parent 0ce0bb8 commit 864496f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions gitalong/gitalong.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,8 +610,13 @@ def managed_repository_files(self) -> list:
to be confused with the files tracked by Gitalong.
"""
git_cmd = self._managed_repository.git
filenames = git_cmd.ls_tree(full_tree=True, name_only=True, r="HEAD")
return filenames.split("\n")
try:
# TODO: HEAD might not be safe here since user could checkout an earlier
# commit.
filenames = git_cmd.ls_tree(full_tree=True, name_only=True, r="HEAD")
return filenames.split("\n")
except git.exc.GitCommandError:
return []

@property
def locally_changed_files(self) -> list:
Expand Down

0 comments on commit 864496f

Please sign in to comment.