From 5be123eaea293183c326ee7e1791a3ffbb0bda59 Mon Sep 17 00:00:00 2001 From: Mario Alvarado Date: Tue, 28 Nov 2023 10:49:28 -0600 Subject: [PATCH] Adding dubious ownership handling --- git/repo/base.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/git/repo/base.py b/git/repo/base.py index 1eb5fe362..a8c0b515a 100644 --- a/git/repo/base.py +++ b/git/repo/base.py @@ -296,6 +296,16 @@ def __init__( else: self.odb = odbt(rootpath) + # Check dubious ownership + try: + if not (self.bare or Git.is_cygwin()): + _ = self.git.status() + except GitCommandError as err: + if "detected dubious ownership" in err.stderr: + err_msg = f"Detected dubious ownership in repository at: {epath}" + raise InvalidGitRepositoryError(err_msg) from None + raise + def __enter__(self) -> "Repo": return self