From df4dabb17c4e83c580d515894dbf7d57912ee554 Mon Sep 17 00:00:00 2001 From: Axel Aguado Date: Sat, 21 Jan 2023 15:38:46 -0600 Subject: Raise exception if return code from check-ignore is not 1 --- git/repo/base.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'git/repo/base.py') diff --git a/git/repo/base.py b/git/repo/base.py index 30f71b0c..9cdf673e 100644 --- a/git/repo/base.py +++ b/git/repo/base.py @@ -873,8 +873,15 @@ class Repo(object): """ try: proc: str = self.git.check_ignore(*paths) - except GitCommandError: - return [] + except GitCommandError as err: + # If return code is 1, this means none of the items in *paths + # are ignored by Git, so return an empty list. Raise the + # exception on all other return codes. + if err.status == 1: + return [] + else: + raise + return proc.replace("\\\\", "\\").replace('"', "").split("\n") @property -- cgit v1.2.1