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

Commitd3d177c

Browse files
authored
Merge pull request#1839 from EliahKagan/refresh-doc
Document manual refresh path treatment
2 parentseba6fce +e9da480 commitd3d177c

File tree

2 files changed

+54
-4
lines changed

2 files changed

+54
-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: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@ def __setstate__(self, d: Dict[str, Any]) -> None:
350350
for, which is not possible under most circumstances.
351351
352352
See:
353+
353354
- :meth:`Git.execute` (on the ``shell`` parameter).
354355
- https://github.com/gitpython-developers/GitPython/commit/0d9390866f9ce42870d3116094cd49e0019a970a
355356
- https://learn.microsoft.com/en-us/windows/win32/procthread/process-creation-flags
@@ -361,15 +362,50 @@ def __setstate__(self, d: Dict[str, Any]) -> None:
361362
GIT_PYTHON_GIT_EXECUTABLE=None
362363
"""Provide the full path to the git executable. Otherwise it assumes git is in the path.
363364
364-
Note that the git executable is actually found during the refresh step in
365-
the top level ``__init__``.
365+
:note: The git executable is actually found during the refresh step in
366+
the top level :mod:`__init__`. It can also be changed by explicitly calling
367+
:func:`git.refresh`.
366368
"""
367369

368370
_refresh_token=object()# Since None would match an initial _version_info_token.
369371

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp