@@ -112,25 +112,25 @@ def handle_process_output(
112
112
This function returns once the finalizer returns.
113
113
114
114
:param process:
115
- :class:`subprocess.Popen` instance
115
+ :class:`subprocess.Popen` instance.
116
116
117
117
:param stdout_handler:
118
- f(stdout_line_string), or None
118
+ f(stdout_line_string), or `` None``.
119
119
120
120
:param stderr_handler:
121
- f(stderr_line_string), or None
121
+ f(stderr_line_string), or `` None``.
122
122
123
123
:param finalizer:
124
- f(proc) - wait for proc to finish
124
+ f(proc) - wait for proc to finish.
125
125
126
126
:param decode_streams:
127
127
Assume stdout/stderr streams are binary and decode them before pushing their
128
128
contents to handlers.
129
- Set this to False if ``universal_newlines == True`` (then streams are in text
130
- mode) or if decoding must happen later (i.e. for :class:`git.diff.Diff`s).
129
+ Set this to `` False`` if ``universal_newlines == True`` (then streams are in
130
+ text mode) or if decoding must happen later (i.e. for :class:`~ git.diff.Diff`s).
131
131
132
132
:param kill_after_timeout:
133
- float or None, Default = None
133
+ :class:` float` or `` None`` , Default = `` None``
134
134
135
135
To specify a timeout in seconds for the git command, after which the process
136
136
should be killed.
@@ -236,7 +236,7 @@ def _safer_popen_windows(
236
236
itself be searched automatically by the shell. This wrapper covers all those cases.
237
237
238
238
:note:
239
- This currently works by setting the `` NoDefaultCurrentDirectoryInExePath` `
239
+ This currently works by setting the :envvar:` NoDefaultCurrentDirectoryInExePath`
240
240
environment variable during subprocess creation. It also takes care of passing
241
241
Windows-specific process creation flags, but that is unrelated to path search.
242
242
@@ -311,8 +311,8 @@ class Git:
311
311
312
312
Debugging:
313
313
314
- * Set the `` GIT_PYTHON_TRACE`` environment variable print each invocation of the
315
- command to stdout.
314
+ * Set the :envvar:` GIT_PYTHON_TRACE` environment variable to print each invocation
315
+ of the command to stdout.
316
316
* Set its value to ``full`` to see details about the returned values.
317
317
"""
318
318
@@ -351,7 +351,7 @@ def __setstate__(self, d: Dict[str, Any]) -> None:
351
351
"""Enables debugging of GitPython's git commands."""
352
352
353
353
USE_SHELL = False
354
- """Deprecated. If set to True, a shell will be used when executing git commands.
354
+ """Deprecated. If set to `` True`` , a shell will be used when executing git commands.
355
355
356
356
Prior to GitPython 2.0.8, this had a narrow purpose in suppressing console windows
357
357
in graphical Windows applications. In 2.0.8 and higher, it provides no benefit, as
@@ -401,30 +401,32 @@ def refresh(cls, path: Union[None, PathLike] = None) -> bool:
401
401
There are three different ways to specify the command that refreshing causes
402
402
to be used for git:
403
403
404
- 1. Pass no `path` argument and do not set the ``GIT_PYTHON_GIT_EXECUTABLE``
405
- environment variable. The command name ``git`` is used. It is looked up
406
- in a path search by the system, in each command run (roughly similar to
407
- how git is found when running `` git`` commands manually). This is usually
408
- the desired behavior.
404
+ 1. Pass no `path` argument and do not set the
405
+ :envvar:`GIT_PYTHON_GIT_EXECUTABLE` environment variable. The command
406
+ name ``git`` is used. It is looked up in a path search by the system, in
407
+ each command run (roughly similar to how git is found when running
408
+ ``git`` commands manually). This is usually the desired behavior.
409
409
410
- 2. Pass no `path` argument but set the `` GIT_PYTHON_GIT_EXECUTABLE` `
410
+ 2. Pass no `path` argument but set the :envvar:` GIT_PYTHON_GIT_EXECUTABLE`
411
411
environment variable. The command given as the value of that variable is
412
412
used. This may be a simple command or an arbitrary path. It is looked up
413
- in each command run. Setting `` GIT_PYTHON_GIT_EXECUTABLE`` to ``git`` has
414
- the same effect as not setting it.
413
+ in each command run. Setting :envvar:` GIT_PYTHON_GIT_EXECUTABLE` to
414
+ ``git`` has the same effect as not setting it.
415
415
416
416
3. Pass a `path` argument. This path, if not absolute, is immediately
417
417
resolved, relative to the current directory. This resolution occurs at
418
418
the time of the refresh. When git commands are run, they are run using
419
419
that previously resolved path. If a `path` argument is passed, the
420
- ``GIT_PYTHON_GIT_EXECUTABLE`` environment variable is not consulted.
420
+ :envvar:`GIT_PYTHON_GIT_EXECUTABLE` environment variable is not
421
+ consulted.
421
422
422
423
:note:
423
424
Refreshing always sets the :attr:`Git.GIT_PYTHON_GIT_EXECUTABLE` class
424
425
attribute, which can be read on the :class:`Git` class or any of its
425
426
instances to check what command is used to run git. This attribute should
426
- not be confused with the related ``GIT_PYTHON_GIT_EXECUTABLE`` environment
427
- variable. The class attribute is set no matter how refreshing is performed.
427
+ not be confused with the related :envvar:`GIT_PYTHON_GIT_EXECUTABLE`
428
+ environment variable. The class attribute is set no matter how refreshing is
429
+ performed.
428
430
"""
429
431
# Discern which path to refresh with.
430
432
if path is not None :
@@ -571,9 +573,9 @@ def polish_url(cls, url: str, is_cygwin: Union[None, bool] = None) -> str:
571
573
def polish_url (cls , url : str , is_cygwin : Union [None , bool ] = None ) -> PathLike :
572
574
"""Remove any backslashes from URLs to be written in config files.
573
575
574
- Windows might create config files containing paths with backslashes,
575
- but git stops liking them as it will escape the backslashes. Hence we
576
- undo the escaping just to be sure.
576
+ Windows might create config files containing paths with backslashes, but git
577
+ stops liking them as it will escape the backslashes. Hence we undo the escaping
578
+ just to be sure.
577
579
"""
578
580
if is_cygwin is None :
579
581
is_cygwin = cls .is_cygwin ()
@@ -638,8 +640,8 @@ class AutoInterrupt:
638
640
639
641
__slots__ = ("proc" , "args" , "status" )
640
642
641
- # If this is non-zero it will override any status code during
642
- # _terminate, used to prevent race conditions in testing.
643
+ # If this is non-zero it will override any status code during _terminate, used
644
+ # to prevent race conditions in testing.
643
645
_status_code_if_terminate : int = 0
644
646
645
647
def __init__ (self , proc : Union [None , subprocess .Popen ], args : Any ) -> None :
@@ -844,7 +846,7 @@ def __init__(self, working_dir: Union[None, PathLike] = None):
844
846
"""Initialize this instance with:
845
847
846
848
:param working_dir:
847
- Git directory we should work in. If None, we always work in the current
849
+ Git directory we should work in. If `` None`` , we always work in the current
848
850
directory as returned by :func:`os.getcwd`.
849
851
This is meant to be the working tree directory if available, or the
850
852
``.git`` directory in case of bare repositories.
@@ -1022,8 +1024,8 @@ def execute(
1022
1024
This feature only has any effect if `as_process` is False.
1023
1025
1024
1026
:param stdout_as_string:
1025
- If False, the command's standard output will be bytes. Otherwise, it will be
1026
- decoded into a string using the default encoding (usually UTF-8).
1027
+ If `` False`` , the command's standard output will be bytes. Otherwise, it
1028
+ will be decoded into a string using the default encoding (usually UTF-8).
1027
1029
The latter can fail, if the output contains binary data.
1028
1030
1029
1031
:param kill_after_timeout:
@@ -1045,15 +1047,16 @@ def execute(
1045
1047
is manually removed.
1046
1048
1047
1049
:param with_stdout:
1048
- If True, default True, we open stdout on the created process.
1050
+ If `` True`` , default `` True`` , we open stdout on the created process.
1049
1051
1050
1052
:param universal_newlines:
1051
- If True, pipes will be opened as text, and lines are split at all known line
1052
- endings.
1053
+ If `` True`` , pipes will be opened as text, and lines are split at all known
1054
+ line endings.
1053
1055
1054
1056
:param shell:
1055
- Whether to invoke commands through a shell (see `Popen(..., shell=True)`).
1056
- If this is not `None`, it overrides :attr:`USE_SHELL`.
1057
+ Whether to invoke commands through a shell
1058
+ (see :class:`Popen(..., shell=True) <subprocess.Popen>`).
1059
+ If this is not ``None``, it overrides :attr:`USE_SHELL`.
1057
1060
1058
1061
Passing ``shell=True`` to this or any other GitPython function should be
1059
1062
avoided, as it is unsafe under most circumstances. This is because it is
@@ -1064,7 +1067,8 @@ def execute(
1064
1067
issues.
1065
1068
1066
1069
:param env:
1067
- A dictionary of environment variables to be passed to :class:`subprocess.Popen`.
1070
+ A dictionary of environment variables to be passed to
1071
+ :class:`subprocess.Popen`.
1068
1072
1069
1073
:param max_chunk_size:
1070
1074
Maximum number of bytes in one chunk of data passed to the `output_stream`
@@ -1083,7 +1087,7 @@ def execute(
1083
1087
* str(output) if extended_output = False (Default)
1084
1088
* tuple(int(status), str(stdout), str(stderr)) if extended_output = True
1085
1089
1086
- If output_stream is True, the stdout value will be your output stream:
1090
+ If ` output_stream` is `` True`` , the stdout value will be your output stream:
1087
1091
1088
1092
* output_stream if extended_output = False
1089
1093
* tuple(int(status), output_stream, str(stderr)) if extended_output = True
@@ -1288,7 +1292,7 @@ def update_environment(self, **kwargs: Any) -> Dict[str, Union[str, None]]:
1288
1292
self.update_environment(**old_env)
1289
1293
1290
1294
:param kwargs:
1291
- Environment variables to use for git processes
1295
+ Environment variables to use for git processes.
1292
1296
1293
1297
:return:
1294
1298
Dict that maps environment variables to their old values
@@ -1367,8 +1371,8 @@ def __call__(self, **kwargs: Any) -> "Git":
1367
1371
1368
1372
:param kwargs:
1369
1373
A dict of keyword arguments.
1370
- These arguments are passed as in :meth:`_call_process`, but will be
1371
- passed to the git command rather than the subcommand.
1374
+ These arguments are passed as in :meth:`_call_process`, but will be passed
1375
+ to the git command rather than the subcommand.
1372
1376
1373
1377
Examples::
1374
1378
@@ -1409,16 +1413,16 @@ def _call_process(
1409
1413
as in ``ls_files`` to call ``ls-files``.
1410
1414
1411
1415
:param args:
1412
- The list of arguments. If None is included, it will be pruned.
1413
- This allows your commands to call git more conveniently, as None is realized
1414
- as non-existent.
1416
+ The list of arguments. If `` None`` is included, it will be pruned.
1417
+ This allows your commands to call git more conveniently, as `` None`` is
1418
+ realized as non-existent.
1415
1419
1416
1420
:param kwargs:
1417
1421
Contains key-values for the following:
1418
1422
1419
1423
- The :meth:`execute()` kwds, as listed in :var:`execute_kwargs`.
1420
1424
- "Command options" to be converted by :meth:`transform_kwargs`.
1421
- - The `' insert_kwargs_after' ` key which its value must match one of ``*args``.
1425
+ - The `` insert_kwargs_after` ` key which its value must match one of ``*args``.
1422
1426
1423
1427
It also contains any command options, to be appended after the matched arg.
1424
1428
@@ -1431,9 +1435,9 @@ def _call_process(
1431
1435
git rev-list max-count 10 --header master
1432
1436
1433
1437
:return:
1434
- Same as :meth:`execute`.
1435
- If no args are given, used :meth:`execute`'s default (especially
1436
- ``as_process = False``, ``stdout_as_string = True``) and return str.
1438
+ Same as :meth:`execute`. If no args are given, used :meth:`execute`'s
1439
+ default (especially ``as_process = False``, ``stdout_as_string = True``) and
1440
+ return :class:` str` .
1437
1441
"""
1438
1442
# Handle optional arguments prior to calling transform_kwargs.
1439
1443
# Otherwise these'll end up in args, which is bad.
@@ -1480,10 +1484,11 @@ def _parse_object_header(self, header_line: str) -> Tuple[str, str, int]:
1480
1484
:param header_line:
1481
1485
<hex_sha> type_string size_as_int
1482
1486
1483
- :return: (hex_sha, type_string, size_as_int)
1487
+ :return:
1488
+ (hex_sha, type_string, size_as_int)
1484
1489
1485
1490
:raise ValueError:
1486
- If the header contains indication for an error due to incorrect input sha
1491
+ If the header contains indication for an error due to incorrect input sha.
1487
1492
"""
1488
1493
tokens = header_line .split ()
1489
1494
if len (tokens ) != 3 :
0 commit comments