Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd7b952e

Browse files
committed
Document manual refresh path treatment
For#1831.
1 parentafa5754 commitd7b952e

File tree

2 files changed

+53
-4
lines changed

2 files changed

+53
-4
lines changed

‎git/__init__.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,21 @@
120120

121121

122122
defrefresh(path:Optional[PathLike]=None)->None:
123-
"""Convenience method for setting the git executable path."""
123+
"""Convenience method for setting the git executable path.
124+
125+
:param path: Optional path to the Git executable. If not absolute, it is resolved
126+
immediately, relative to the current directory.
127+
128+
:note: The *path* parameter is usually omitted and cannot be used to specify a
129+
custom command whose location is looked up in a path search on each call. See
130+
:meth:`Git.refresh` for details on how to achieve this.
131+
132+
:note: This calls :meth:`Git.refresh` and sets other global configuration according
133+
to the effect of doing so. As such, this function should usually be used instead
134+
of using :meth:`Git.refresh` or :meth:`FetchInfo.refresh` directly.
135+
136+
:note: This function is called automatically, with no arguments, at import time.
137+
"""
124138
globalGIT_OK
125139
GIT_OK=False
126140

‎git/cmd.py

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -355,13 +355,48 @@ def __setstate__(self, d: Dict[str, Any]) -> None:
355355
GIT_PYTHON_GIT_EXECUTABLE=None
356356
"""Provide the full path to the git executable. Otherwise it assumes git is in the path.
357357
358-
Note that the git executable is actually found during the refresh step in
359-
the top level ``__init__``.
358+
:note: The git executable is actually found during the refresh step in
359+
the top level :mod:`__init__`. It can also be changed by explicitly calling
360+
:func:`git.refresh`.
360361
"""
361362

362363
@classmethod
363364
defrefresh(cls,path:Union[None,PathLike]=None)->bool:
364-
"""This gets called by the refresh function (see the top level __init__)."""
365+
"""This gets called by the refresh function (see the top level __init__).
366+
367+
:param path: Optional path to the git executable. If not absolute, it is
368+
resolved immediately, relative to the current directory. (See note below.)
369+
370+
:note: The top-level :func:`git.refresh` should be preferred because it calls
371+
this method and may also update other state accordingly.
372+
373+
:note: There are three different ways to specify what command refreshing causes
374+
to be uses for git:
375+
376+
1. Pass no *path* argument and do not set the ``GIT_PYTHON_GIT_EXECUTABLE``
377+
environment variable. The command name ``git`` is used. It is looked up
378+
in a path search by the system, in each command run (roughly similar to
379+
how git is found when running ``git`` commands manually). This is usually
380+
the desired behavior.
381+
382+
2. Pass no *path* argument but set the ``GIT_PYTHON_GIT_EXECUTABLE``
383+
environment variable. The command given as the value of that variable is
384+
used. This may be a simple command or an arbitrary path. It is looked up
385+
in each command run. Setting ``GIT_PYTHON_GIT_EXECUTABLE`` to ``git`` has
386+
the same effect as not setting it.
387+
388+
3. Pass a *path* argument. This path, if not absolute, it immediately
389+
resolved, relative to the current directory. This resolution occurs at
390+
the time of the refresh, and when git commands are run, they are run with
391+
that actual path. If a *path* argument is passed, the
392+
``GIT_PYTHON_GIT_EXECUTABLE`` environment variable is not consulted.
393+
394+
:note: Refreshing always sets the :attr:`Git.GIT_PYTHON_GIT_EXECUTABLE` class
395+
attribute, which can be read on the :class:`Git` class or any of its
396+
instances to check what command is used to run git. This attribute should
397+
not be confused with the related ``GIT_PYTHON_GIT_EXECUTABLE`` environment
398+
variable. The class attribute is set no matter how refreshing is performed.
399+
"""
365400
# Discern which path to refresh with.
366401
ifpathisnotNone:
367402
new_git=os.path.expanduser(path)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp