From 1808dddfa64b79a05e678f57bfe87a4b6aca9cfe 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/cmd.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/git/cmd.py b/git/cmd.py index 5f96e33c9..d67bb1478 100644 --- a/git/cmd.py +++ b/git/cmd.py @@ -1322,7 +1322,12 @@ def _parse_object_header(self, header_line: str) -> Tuple[str, str, int]: tokens = header_line.split() if len(tokens) != 3: if not tokens: - raise ValueError("SHA could not be resolved, git returned: %r" % (header_line.strip())) + err_msg = ( + f"SHA is empty, possible dubious ownership in the repository " + f"""at {self._working_dir}.\n If this is unintended run:\n\n """ + f""" "git config --global --add safe.directory {self._working_dir}" """ + ) + raise ValueError(err_msg) else: raise ValueError("SHA %s could not be resolved, git returned: %r" % (tokens[0], header_line.strip())) # END handle actual return value