diff --git a/aider/coders/base_coder.py b/aider/coders/base_coder.py index 0889e0d1a..9ec8bf547 100755 --- a/aider/coders/base_coder.py +++ b/aider/coders/base_coder.py @@ -1784,7 +1784,7 @@ class Coder: self.reflected_message = str(err) return edited - except git.exc.ODBError as err: + except (git.exc.ODBError, git.exc.GitError) as err: self.io.tool_error(str(err)) return edited except Exception as err: diff --git a/aider/coders/search_replace.py b/aider/coders/search_replace.py index 1fdcff343..f89f629cb 100755 --- a/aider/coders/search_replace.py +++ b/aider/coders/search_replace.py @@ -484,7 +484,7 @@ def git_cherry_pick_osr_onto_o(texts): # cherry pick R onto original try: repo.git.cherry_pick(replace_hash, "--minimal") - except git.exc.ODBError: + except (git.exc.ODBError, git.exc.GitError): # merge conflicts! return @@ -522,7 +522,7 @@ def git_cherry_pick_sr_onto_so(texts): # cherry pick replace onto original try: repo.git.cherry_pick(replace_hash, "--minimal") - except git.exc.ODBError: + except (git.exc.ODBError, git.exc.GitError): # merge conflicts! return diff --git a/aider/commands.py b/aider/commands.py index 244114623..c5c7a3abd 100644 --- a/aider/commands.py +++ b/aider/commands.py @@ -450,7 +450,7 @@ class Commands: try: remote_head = self.coder.repo.repo.git.rev_parse(f"origin/{current_branch}") has_origin = True - except git.exc.ODBError: + except (git.exc.ODBError, git.exc.GitError): has_origin = False if has_origin: diff --git a/aider/main.py b/aider/main.py index 16d458e24..0bd2c9e8d 100644 --- a/aider/main.py +++ b/aider/main.py @@ -56,8 +56,7 @@ def make_new_repo(git_root, io): try: repo = git.Repo.init(git_root) check_gitignore(git_root, io, False) - except (git.exc.ODBError, git.exc.GitCommandNotFound) as err: # issue #1233 - # git.exc.GitCommandNotFound is not a subclass of git.exc.ODBError + except (git.exc.ODBError, git.exc.GitError) as err: # issue #1233 io.tool_error(f"Unable to create git repo in {git_root}") io.tool_error(str(err)) return @@ -115,8 +114,7 @@ def check_gitignore(git_root, io, ask=True): repo = git.Repo(git_root) if repo.ignored(".aider"): return - except (git.exc.ODBError, git.exc.GitCommandNotFound): - # git.exc.GitCommandNotFound is not a subclass of git.exc.ODBError + except (git.exc.ODBError, git.exc.GitError): pass pat = ".aider*" diff --git a/aider/repo.py b/aider/repo.py index 69aafa4a8..6a4effb9c 100644 --- a/aider/repo.py +++ b/aider/repo.py @@ -71,7 +71,7 @@ class GitRepo: repo_path = git.Repo(fname, search_parent_directories=True).working_dir repo_path = utils.safe_abs_path(repo_path) repo_paths.append(repo_path) - except git.exc.ODBError: + except (git.exc.ODBError, git.exc.GitError): pass num_repos = len(set(repo_paths)) @@ -205,7 +205,7 @@ class GitRepo: try: commits = self.repo.iter_commits(active_branch) current_branch_has_commits = any(commits) - except git.exc.ODBError: + except (git.exc.ODBError, git.exc.GitError): pass except TypeError: pass @@ -373,7 +373,7 @@ class GitRepo: def get_head_commit(self): try: return self.repo.head.commit - except (ValueError, git.exc.ODBError): + except (ValueError, git.exc.ODBError, git.exc.GitError): return None def get_head_commit_sha(self, short=False):