Skip to content

Commit df4dabb

Browse files
committed
Raise exception if return code from check-ignore is not 1
1 parent 2ddb604 commit df4dabb

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Diff for: git/repo/base.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -873,8 +873,15 @@ def ignored(self, *paths: PathLike) -> List[str]:
873873
"""
874874
try:
875875
proc: str = self.git.check_ignore(*paths)
876-
except GitCommandError:
877-
return []
876+
except GitCommandError as err:
877+
# If return code is 1, this means none of the items in *paths
878+
# are ignored by Git, so return an empty list. Raise the
879+
# exception on all other return codes.
880+
if err.status == 1:
881+
return []
882+
else:
883+
raise
884+
878885
return proc.replace("\\\\", "\\").replace('"', "").split("\n")
879886

880887
@property

0 commit comments

Comments
 (0)