From a11b89a40eb3a3b8197b0a8966cf54f4d63d5e3f Mon Sep 17 00:00:00 2001 From: Eliah Kagan Date: Tue, 23 Jan 2024 23:11:34 -0500 Subject: [PATCH 1/2] Clarify why GIT_PYTHON_GIT_EXECUTABLE may be set on failure This clarifies the comment that explains the significance of setting the Git.GIT_PYTHON_GIT_EXECUTABLE attribute when running Git failed but the attribute wasn't set before. This happens in the code path in Git.refresh where has_git is False and old_git is None, provided the refresh mode doesn't call for the initial refresh to raise an exception on failure. It was previously described in terms of a "first" and "second" import, but as discussed in #1804, the rationale and effect were not altogether clear. --- git/cmd.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/git/cmd.py b/git/cmd.py index 4413182e0..76b71e98e 100644 --- a/git/cmd.py +++ b/git/cmd.py @@ -475,9 +475,10 @@ def refresh(cls, path: Union[None, PathLike] = None) -> bool: ) raise ImportError(err) - # We get here if this was the init refresh and the refresh mode was not - # error. Go ahead and set the GIT_PYTHON_GIT_EXECUTABLE such that we - # discern the difference between a first import and a second import. + # We get here if this was the initial refresh and the refresh mode was + # not error. Go ahead and set the GIT_PYTHON_GIT_EXECUTABLE such that we + # discern the the difference between the first refresh at import time + # and subsequent calls to refresh. cls.GIT_PYTHON_GIT_EXECUTABLE = cls.git_exec_name else: # After the first refresh (when GIT_PYTHON_GIT_EXECUTABLE is no longer From 82cbc6c58e6949a9b92aa30df78f9ce98f40ab02 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Wed, 24 Jan 2024 08:44:28 +0100 Subject: [PATCH 2/2] Apply suggestions from code review --- git/cmd.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/git/cmd.py b/git/cmd.py index 76b71e98e..24ba71b5f 100644 --- a/git/cmd.py +++ b/git/cmd.py @@ -477,8 +477,8 @@ def refresh(cls, path: Union[None, PathLike] = None) -> bool: # We get here if this was the initial refresh and the refresh mode was # not error. Go ahead and set the GIT_PYTHON_GIT_EXECUTABLE such that we - # discern the the difference between the first refresh at import time - # and subsequent calls to refresh. + # discern the difference between the first refresh at import time + # and subsequent calls to refresh(). cls.GIT_PYTHON_GIT_EXECUTABLE = cls.git_exec_name else: # After the first refresh (when GIT_PYTHON_GIT_EXECUTABLE is no longer