GitPython 3.1.43__py3-none-any.whl → 3.1.44__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -54,5 +54,6 @@ Contributors are:
54
54
  -Wenhan Zhu <wzhu.cosmos _at_ gmail.com>
55
55
  -Eliah Kagan <eliah.kagan _at_ gmail.com>
56
56
  -Ethan Lin <et.repositories _at_ gmail.com>
57
+ -Jonas Scharpf <jonas.scharpf _at_ checkmk.com>
57
58
 
58
59
  Portions derived from other open source works and are clearly marked.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: GitPython
3
- Version: 3.1.43
3
+ Version: 3.1.44
4
4
  Summary: GitPython is a Python library used to interact with Git repositories
5
5
  Home-page: https://github.com/gitpython-developers/GitPython
6
6
  Author: Sebastian Thiel, Michael Trier
@@ -27,29 +27,24 @@ Requires-Python: >=3.7
27
27
  Description-Content-Type: text/markdown
28
28
  License-File: LICENSE
29
29
  License-File: AUTHORS
30
- Requires-Dist: gitdb <5,>=4.0.1
31
- Requires-Dist: typing-extensions >=3.7.4.3 ; python_version < "3.8"
32
- Provides-Extra: doc
33
- Requires-Dist: sphinx ==4.3.2 ; extra == 'doc'
34
- Requires-Dist: sphinx-rtd-theme ; extra == 'doc'
35
- Requires-Dist: sphinxcontrib-applehelp <=1.0.4,>=1.0.2 ; extra == 'doc'
36
- Requires-Dist: sphinxcontrib-devhelp ==1.0.2 ; extra == 'doc'
37
- Requires-Dist: sphinxcontrib-htmlhelp <=2.0.1,>=2.0.0 ; extra == 'doc'
38
- Requires-Dist: sphinxcontrib-qthelp ==1.0.3 ; extra == 'doc'
39
- Requires-Dist: sphinxcontrib-serializinghtml ==1.1.5 ; extra == 'doc'
40
- Requires-Dist: sphinx-autodoc-typehints ; extra == 'doc'
30
+ Requires-Dist: gitdb<5,>=4.0.1
31
+ Requires-Dist: typing-extensions>=3.7.4.3; python_version < "3.8"
41
32
  Provides-Extra: test
42
- Requires-Dist: coverage[toml] ; extra == 'test'
43
- Requires-Dist: ddt !=1.4.3,>=1.1.1 ; extra == 'test'
44
- Requires-Dist: mypy ; extra == 'test'
45
- Requires-Dist: pre-commit ; extra == 'test'
46
- Requires-Dist: pytest >=7.3.1 ; extra == 'test'
47
- Requires-Dist: pytest-cov ; extra == 'test'
48
- Requires-Dist: pytest-instafail ; extra == 'test'
49
- Requires-Dist: pytest-mock ; extra == 'test'
50
- Requires-Dist: pytest-sugar ; extra == 'test'
51
- Requires-Dist: typing-extensions ; (python_version < "3.11") and extra == 'test'
52
- Requires-Dist: mock ; (python_version < "3.8") and extra == 'test'
33
+ Requires-Dist: coverage[toml]; extra == "test"
34
+ Requires-Dist: ddt!=1.4.3,>=1.1.1; extra == "test"
35
+ Requires-Dist: mock; python_version < "3.8" and extra == "test"
36
+ Requires-Dist: mypy; extra == "test"
37
+ Requires-Dist: pre-commit; extra == "test"
38
+ Requires-Dist: pytest>=7.3.1; extra == "test"
39
+ Requires-Dist: pytest-cov; extra == "test"
40
+ Requires-Dist: pytest-instafail; extra == "test"
41
+ Requires-Dist: pytest-mock; extra == "test"
42
+ Requires-Dist: pytest-sugar; extra == "test"
43
+ Requires-Dist: typing-extensions; python_version < "3.11" and extra == "test"
44
+ Provides-Extra: doc
45
+ Requires-Dist: sphinx<7.2,>=7.1.2; extra == "doc"
46
+ Requires-Dist: sphinx_rtd_theme; extra == "doc"
47
+ Requires-Dist: sphinx-autodoc-typehints; extra == "doc"
53
48
 
54
49
  ![Python package](https://github.com/gitpython-developers/GitPython/workflows/Python%20package/badge.svg)
55
50
  [![Documentation Status](https://readthedocs.org/projects/gitpython/badge/?version=stable)](https://readthedocs.org/projects/gitpython/?badge=stable)
@@ -154,7 +149,7 @@ In the less common case that you do not want to install test dependencies, `pip
154
149
 
155
150
  #### With editable *dependencies* (not preferred, and rarely needed)
156
151
 
157
- In rare cases, you may want to work on GitPython and one or both of its [gitdb](https://github.com/gitpython-developers/gitdb) and [smmap](https://github.com/gitpython-developers/smmap) dependencies at the same time, with changes in your local working copy of gitdb or smmap immediatley reflected in the behavior of your local working copy of GitPython. This can be done by making editable installations of those dependencies in the same virtual environment where you install GitPython.
152
+ In rare cases, you may want to work on GitPython and one or both of its [gitdb](https://github.com/gitpython-developers/gitdb) and [smmap](https://github.com/gitpython-developers/smmap) dependencies at the same time, with changes in your local working copy of gitdb or smmap immediately reflected in the behavior of your local working copy of GitPython. This can be done by making editable installations of those dependencies in the same virtual environment where you install GitPython.
158
153
 
159
154
  If you want to do that *and* you want the versions in GitPython's git submodules to be used, then pass `-e git/ext/gitdb` and/or `-e git/ext/gitdb/gitdb/ext/smmap` to `pip install`. This can be done in any order, and in separate `pip install` commands or the same one, so long as `-e` appears before *each* path. For example, you can install GitPython, gitdb, and smmap editably in the currently active virtual environment this way:
160
155
 
@@ -293,5 +288,8 @@ Please have a look at the [contributions file][contributing].
293
288
 
294
289
  [3-Clause BSD License](https://opensource.org/license/bsd-3-clause/), also known as the New BSD License. See the [LICENSE file][license].
295
290
 
291
+ One file exclusively used for fuzz testing is subject to [a separate license, detailed here](./fuzzing/README.md#license).
292
+ This file is not included in the wheel or sdist packages published by the maintainers of GitPython.
293
+
296
294
  [contributing]: https://github.com/gitpython-developers/GitPython/blob/main/CONTRIBUTING.md
297
295
  [license]: https://github.com/gitpython-developers/GitPython/blob/main/LICENSE
@@ -1,44 +1,44 @@
1
- git/__init__.py,sha256=w6fnS0QmwTfEFUSL6rfnpP0lUId2goSguZFOvVX3N3U,8899
2
- git/cmd.py,sha256=qd-gIHSk4mfsYjd9YA08cPyO8TMxaibTXAbFnHK71uc,67659
1
+ git/__init__.py,sha256=nkQImgv-bWdiZOFDjzN-gbt93FoRHD0nY6_t9LQxy4Y,8899
2
+ git/cmd.py,sha256=QwiaBy0mFbi9xjRKhRgUVK-_-K6xVdFqh9l0cxPqPSc,67724
3
3
  git/compat.py,sha256=y1E6y6O2q5r8clSlr8ZNmuIWG9nmHuehQEsVsmBffs8,4526
4
- git/config.py,sha256=Ald8Xc-G9Shcgx3QCISyXTkL4a6nbc3qll-xUw4YdyY,34924
4
+ git/config.py,sha256=vTUlK6d8ORqFqjOv4Vbq_Hm-5mp-jOAt1dkq0IdzJ3U,34933
5
5
  git/db.py,sha256=vIW9uWSbqu99zbuU2ZDmOhVOv1UPTmxrnqiCtRHCfjE,2368
6
- git/diff.py,sha256=IE5aeHL7aP9yxBluYj06IX8nZjoJ_TOM3gG31-Evf_8,27058
6
+ git/diff.py,sha256=wmpMCIdMiVOqreGVPOGYyO4gFboGOAicyrvvI7PPjEg,27095
7
7
  git/exc.py,sha256=Gc7g1pHpn8OmTse30NHmJVsBJ2CYH8LxaR8y8UA3lIM,7119
8
8
  git/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
- git/remote.py,sha256=IHQ3BvXgoIN1EvHlyH3vrSaQoDkLOE6nooSC0w183sU,46561
10
- git/types.py,sha256=xCwpp2Y01lhS0MapHhj04m0P_x34kwSD1Gsou_ZPWj8,10251
11
- git/util.py,sha256=1E883mnPAFLyFk7ivwnEremsp-uJOTc3ks_QypyLung,43651
9
+ git/remote.py,sha256=pYn9dAlz-QwvNMWXD1M57pMPQitthOM86qTRK_cpTqU,46786
10
+ git/types.py,sha256=MQzIDEOnoueXGsAJF_0MgUc_osH7Eu0Sw3DQofYzCVE,10272
11
+ git/util.py,sha256=2uAv34zZ_827-zJ3-D5ACrVH-4Q4EO_KLUTH23zi2AI,43770
12
12
  git/index/__init__.py,sha256=i-Nqb8Lufp9aFbmxpQBORmmQnjEVVM1Pn58fsQkyGgQ,406
13
- git/index/base.py,sha256=A4q4cN_Ifxi8CsAR-7h4KsQ2d3JazBNFZ1ltbAKttgs,60734
13
+ git/index/base.py,sha256=nDD7XVLNbgBKpJMrrTVyHBy6NVLWgDkk7oUw6ZOegPc,60808
14
14
  git/index/fun.py,sha256=37cA3DBC9vpAnSVu5TGA072SnoF5XZOkOukExwlejHs,16736
15
15
  git/index/typ.py,sha256=uuKNwitUw83FhVaLSwo4pY7PHDQudtZTLJrLGym4jcI,6570
16
16
  git/index/util.py,sha256=fULi7GPG-MvprKrRCD5c15GNdzku_1E38We0d97WB3A,3659
17
17
  git/objects/__init__.py,sha256=O6ZL_olX7e5-8iIbKviRPkVSJxN37WA-EC0q9d48U5Y,637
18
18
  git/objects/base.py,sha256=0dqNkSRVH0mk0-7ZKIkGBK7iNYrzLTVxwQFUd6CagsE,10277
19
19
  git/objects/blob.py,sha256=zwwq0KfOMYeP5J2tW5CQatoLyeqFRlfkxP1Vwx1h07s,1215
20
- git/objects/commit.py,sha256=vLZNl1I9zp17Rpge7J66CvsryirEs90jyPTQzoP0JJs,30208
20
+ git/objects/commit.py,sha256=GH1_83C9t7RGTukwozTHDgvxYQPRjTHhPDkXJyBbJyo,30553
21
21
  git/objects/fun.py,sha256=B4jCqhAjm6Hl79GK58FPzW1H9K6Wc7Tx0rssyWmAcEE,8935
22
- git/objects/tag.py,sha256=gAx8i-DEwy_Z3R2zLkvetYRV8A56BCcTr3iLuTUTfEM,4467
22
+ git/objects/tag.py,sha256=jAGESnpmTEv-dLakPzheT5ILZFFArcItnXYqfxfDrgc,4441
23
23
  git/objects/tree.py,sha256=jJH888SHiP4dGzE-ra1yenQOyya_0C_MkHr06c1gHpM,13849
24
- git/objects/util.py,sha256=Ml2eqZPKO4y9Hc2vWbXJgpsK3nkN3KGMzbn8AlzLyYQ,23834
24
+ git/objects/util.py,sha256=Nlza4zLgdPmr_Yasyvvs6c1rKtW_wMxI6wDmQpQ3ufw,23846
25
25
  git/objects/submodule/__init__.py,sha256=6xySp767LVz3UylWgUalntS_nGXRuVzXxDuFAv_Wc2c,303
26
26
  git/objects/submodule/base.py,sha256=MQ-2xV8JznGwy2hLQv1aeQNgAkhBhgc5tdtClFL3DmE,63901
27
27
  git/objects/submodule/root.py,sha256=5eTtYNHasqdPq6q0oDCPr7IaO6uAHL3b4DxMoiO2LhE,20246
28
28
  git/objects/submodule/util.py,sha256=sQqAYaiSJdFkZa9NlAuK_wTsMNiS-kkQnQjvIoJtc_o,3509
29
29
  git/refs/__init__.py,sha256=DWlJNnsx-4jM_E-VycbP-FZUdn6iWhjnH_uZ_pZXBro,509
30
- git/refs/head.py,sha256=GAZpD5EfqSciDXPtgjHY8ZbBixKExJRhojUB-HrrJPg,10491
30
+ git/refs/head.py,sha256=SGa3N301HfAi79X6UR5Mcg7mO9TnCH3Bk549kHlJVaQ,10513
31
31
  git/refs/log.py,sha256=kXiuAgTo1DIuM_BfbDUk9gQ0YO-mutIMVdHv1_ES90o,12493
32
32
  git/refs/reference.py,sha256=l6mhF4YLSEwtjz6b9PpOQH-fkng7EYWMaJhkjn-2jXA,5630
33
33
  git/refs/remote.py,sha256=WwqV9T7BbYf3F_WZNUQivu9xktIIKGklCjDpwQrhD-A,2806
34
34
  git/refs/symbolic.py,sha256=c8zOwaqzcg-J-rGrpuWdvh8zwMvSUqAHghd4vJoYG_s,34552
35
35
  git/refs/tag.py,sha256=kgzV2vhpL4FD2TqHb0BJuMRAHgAvJF-TcoyWlaB-djQ,5010
36
36
  git/repo/__init__.py,sha256=CILSVH36fX_WxVFSjD9o1WF5LgsNedPiJvSngKZqfVU,210
37
- git/repo/base.py,sha256=mitfJ8u99CsMpDd7_VRyx-SF8omu2tpf3lqzSaQkKoQ,59353
38
- git/repo/fun.py,sha256=tEsClpmbOrKMSNIdncOB_6JdikrL1-AfkOFd7xMpD8k,13582
39
- GitPython-3.1.43.dist-info/AUTHORS,sha256=h1TlPKfp05GA1eKQ15Yl4biR0C0FgivuGSeRA6Q1dz0,2286
40
- GitPython-3.1.43.dist-info/LICENSE,sha256=hvyUwyGpr7wRUUcTURuv3tIl8lEA3MD3NQ6CvCMbi-s,1503
41
- GitPython-3.1.43.dist-info/METADATA,sha256=sAh3r1BMVw5_olGgDmpMS69zBpVr7UEOeRivNHKznfU,13376
42
- GitPython-3.1.43.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
43
- GitPython-3.1.43.dist-info/top_level.txt,sha256=0hzDuIp8obv624V3GmbqsagBWkk8ohtGU-Bc1PmTT0o,4
44
- GitPython-3.1.43.dist-info/RECORD,,
37
+ git/repo/base.py,sha256=0GU6nKNdT8SYjDI5Y5DeZ1zCEX3tHeq1VW2MSpne05g,59891
38
+ git/repo/fun.py,sha256=HSGC0-rqeKKx9fDg7JyQyMZgIwUWn-FnSZR_gRGpG-E,13573
39
+ GitPython-3.1.44.dist-info/AUTHORS,sha256=tZ9LuyBks2V2HKTPK7kCmtd9Guu_LyU1oZHvU0NiAok,2334
40
+ GitPython-3.1.44.dist-info/LICENSE,sha256=hvyUwyGpr7wRUUcTURuv3tIl8lEA3MD3NQ6CvCMbi-s,1503
41
+ GitPython-3.1.44.dist-info/METADATA,sha256=0O_Fr2Y7A-DlPYhlbSxGjblBC2mWkw3USNUhyL80Ip8,13245
42
+ GitPython-3.1.44.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
43
+ GitPython-3.1.44.dist-info/top_level.txt,sha256=0hzDuIp8obv624V3GmbqsagBWkk8ohtGU-Bc1PmTT0o,4
44
+ GitPython-3.1.44.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.43.0)
2
+ Generator: setuptools (75.6.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
git/__init__.py CHANGED
@@ -86,7 +86,7 @@ __all__ = [
86
86
  "to_hex_sha",
87
87
  ]
88
88
 
89
- __version__ = '3.1.43'
89
+ __version__ = '3.1.44'
90
90
 
91
91
  from typing import Any, List, Optional, Sequence, TYPE_CHECKING, Tuple, Union
92
92
 
git/cmd.py CHANGED
@@ -1269,6 +1269,7 @@ class Git(metaclass=_GitMeta):
1269
1269
  stdout=stdout_sink,
1270
1270
  shell=shell,
1271
1271
  universal_newlines=universal_newlines,
1272
+ encoding=defenc if universal_newlines else None,
1272
1273
  **subprocess_kwargs,
1273
1274
  )
1274
1275
  except cmd_not_found_exception as err:
git/config.py CHANGED
@@ -452,7 +452,7 @@ class GitConfigParser(cp.RawConfigParser, metaclass=MetaParserBuilder):
452
452
  e = None # None, or an exception.
453
453
 
454
454
  def string_decode(v: str) -> str:
455
- if v[-1] == "\\":
455
+ if v and v.endswith("\\"):
456
456
  v = v[:-1]
457
457
  # END cut trailing escapes to prevent decode error
458
458
 
git/diff.py CHANGED
@@ -187,7 +187,7 @@ class Diffable:
187
187
  paths: Union[PathLike, List[PathLike], Tuple[PathLike, ...], None] = None,
188
188
  create_patch: bool = False,
189
189
  **kwargs: Any,
190
- ) -> "DiffIndex":
190
+ ) -> "DiffIndex[Diff]":
191
191
  """Create diffs between two items being trees, trees and index or an index and
192
192
  the working tree. Detects renames automatically.
193
193
 
@@ -325,7 +325,7 @@ class DiffIndex(List[T_Diff]):
325
325
  yield diffidx
326
326
  elif change_type == "C" and diffidx.copied_file:
327
327
  yield diffidx
328
- elif change_type == "R" and diffidx.renamed:
328
+ elif change_type == "R" and diffidx.renamed_file:
329
329
  yield diffidx
330
330
  elif change_type == "M" and diffidx.a_blob and diffidx.b_blob and diffidx.a_blob != diffidx.b_blob:
331
331
  yield diffidx
@@ -581,7 +581,7 @@ class Diff:
581
581
  return None
582
582
 
583
583
  @classmethod
584
- def _index_from_patch_format(cls, repo: "Repo", proc: Union["Popen", "Git.AutoInterrupt"]) -> DiffIndex:
584
+ def _index_from_patch_format(cls, repo: "Repo", proc: Union["Popen", "Git.AutoInterrupt"]) -> DiffIndex["Diff"]:
585
585
  """Create a new :class:`DiffIndex` from the given process output which must be
586
586
  in patch format.
587
587
 
@@ -674,7 +674,7 @@ class Diff:
674
674
  return index
675
675
 
676
676
  @staticmethod
677
- def _handle_diff_line(lines_bytes: bytes, repo: "Repo", index: DiffIndex) -> None:
677
+ def _handle_diff_line(lines_bytes: bytes, repo: "Repo", index: DiffIndex["Diff"]) -> None:
678
678
  lines = lines_bytes.decode(defenc)
679
679
 
680
680
  # Discard everything before the first colon, and the colon itself.
@@ -695,7 +695,7 @@ class Diff:
695
695
  change_type: Lit_change_type = cast(Lit_change_type, _change_type[0])
696
696
  score_str = "".join(_change_type[1:])
697
697
  score = int(score_str) if score_str.isdigit() else None
698
- path = path.strip()
698
+ path = path.strip("\n")
699
699
  a_path = path.encode(defenc)
700
700
  b_path = path.encode(defenc)
701
701
  deleted_file = False
@@ -747,7 +747,7 @@ class Diff:
747
747
  index.append(diff)
748
748
 
749
749
  @classmethod
750
- def _index_from_raw_format(cls, repo: "Repo", proc: "Popen") -> "DiffIndex":
750
+ def _index_from_raw_format(cls, repo: "Repo", proc: "Popen") -> "DiffIndex[Diff]":
751
751
  """Create a new :class:`DiffIndex` from the given process output which must be
752
752
  in raw format.
753
753
 
git/index/base.py CHANGED
@@ -28,6 +28,7 @@ from git.exc import CheckoutError, GitCommandError, GitError, InvalidGitReposito
28
28
  from git.objects import Blob, Commit, Object, Submodule, Tree
29
29
  from git.objects.util import Serializable
30
30
  from git.util import (
31
+ Actor,
31
32
  LazyMixin,
32
33
  LockedFD,
33
34
  join_path_native,
@@ -76,7 +77,6 @@ if TYPE_CHECKING:
76
77
 
77
78
  from git.refs.reference import Reference
78
79
  from git.repo import Repo
79
- from git.util import Actor
80
80
 
81
81
 
82
82
  Treeish = Union[Tree, Commit, str, bytes]
@@ -653,12 +653,12 @@ class IndexFile(LazyMixin, git_diff.Diffable, Serializable):
653
653
  return path
654
654
  if self.repo.bare:
655
655
  raise InvalidGitRepositoryError("require non-bare repository")
656
- if not str(path).startswith(str(self.repo.working_tree_dir)):
656
+ if not osp.normpath(str(path)).startswith(str(self.repo.working_tree_dir)):
657
657
  raise ValueError("Absolute path %r is not in git repository at %r" % (path, self.repo.working_tree_dir))
658
658
  return os.path.relpath(path, self.repo.working_tree_dir)
659
659
 
660
660
  def _preprocess_add_items(
661
- self, items: Sequence[Union[PathLike, Blob, BaseIndexEntry, "Submodule"]]
661
+ self, items: Union[PathLike, Sequence[Union[PathLike, Blob, BaseIndexEntry, "Submodule"]]]
662
662
  ) -> Tuple[List[PathLike], List[BaseIndexEntry]]:
663
663
  """Split the items into two lists of path strings and BaseEntries."""
664
664
  paths = []
@@ -749,7 +749,7 @@ class IndexFile(LazyMixin, git_diff.Diffable, Serializable):
749
749
 
750
750
  def add(
751
751
  self,
752
- items: Sequence[Union[PathLike, Blob, BaseIndexEntry, "Submodule"]],
752
+ items: Union[PathLike, Sequence[Union[PathLike, Blob, BaseIndexEntry, "Submodule"]]],
753
753
  force: bool = True,
754
754
  fprogress: Callable = lambda *args: None,
755
755
  path_rewriter: Union[Callable[..., PathLike], None] = None,
@@ -976,7 +976,7 @@ class IndexFile(LazyMixin, git_diff.Diffable, Serializable):
976
976
  @default_index
977
977
  def remove(
978
978
  self,
979
- items: Sequence[Union[PathLike, Blob, BaseIndexEntry, "Submodule"]],
979
+ items: Union[PathLike, Sequence[Union[PathLike, Blob, BaseIndexEntry, "Submodule"]]],
980
980
  working_tree: bool = False,
981
981
  **kwargs: Any,
982
982
  ) -> List[str]:
@@ -1036,7 +1036,7 @@ class IndexFile(LazyMixin, git_diff.Diffable, Serializable):
1036
1036
  @default_index
1037
1037
  def move(
1038
1038
  self,
1039
- items: Sequence[Union[PathLike, Blob, BaseIndexEntry, "Submodule"]],
1039
+ items: Union[PathLike, Sequence[Union[PathLike, Blob, BaseIndexEntry, "Submodule"]]],
1040
1040
  skip_errors: bool = False,
1041
1041
  **kwargs: Any,
1042
1042
  ) -> List[Tuple[str, str]]:
@@ -1117,8 +1117,8 @@ class IndexFile(LazyMixin, git_diff.Diffable, Serializable):
1117
1117
  message: str,
1118
1118
  parent_commits: Union[List[Commit], None] = None,
1119
1119
  head: bool = True,
1120
- author: Union[None, "Actor"] = None,
1121
- committer: Union[None, "Actor"] = None,
1120
+ author: Union[None, Actor] = None,
1121
+ committer: Union[None, Actor] = None,
1122
1122
  author_date: Union[datetime.datetime, str, None] = None,
1123
1123
  commit_date: Union[datetime.datetime, str, None] = None,
1124
1124
  skip_hooks: bool = False,
@@ -1443,7 +1443,7 @@ class IndexFile(LazyMixin, git_diff.Diffable, Serializable):
1443
1443
  key = entry_key(path, 0)
1444
1444
  self.entries[key] = nie[key]
1445
1445
  except KeyError:
1446
- # If key is not in theirs, it musn't be in ours.
1446
+ # If key is not in theirs, it mustn't be in ours.
1447
1447
  try:
1448
1448
  del self.entries[key]
1449
1449
  except KeyError:
@@ -1478,7 +1478,7 @@ class IndexFile(LazyMixin, git_diff.Diffable, Serializable):
1478
1478
  paths: Union[PathLike, List[PathLike], Tuple[PathLike, ...], None] = None,
1479
1479
  create_patch: bool = False,
1480
1480
  **kwargs: Any,
1481
- ) -> git_diff.DiffIndex:
1481
+ ) -> git_diff.DiffIndex[git_diff.Diff]:
1482
1482
  """Diff this index against the working copy or a :class:`~git.objects.tree.Tree`
1483
1483
  or :class:`~git.objects.commit.Commit` object.
1484
1484
 
git/objects/commit.py CHANGED
@@ -377,15 +377,25 @@ class Commit(base.Object, TraversableIterableObj, Diffable, Serializable):
377
377
  :return:
378
378
  :class:`Stats`
379
379
  """
380
- if not self.parents:
381
- text = self.repo.git.diff_tree(self.hexsha, "--", numstat=True, no_renames=True, root=True)
382
- text2 = ""
383
- for line in text.splitlines()[1:]:
380
+
381
+ def process_lines(lines: List[str]) -> str:
382
+ text = ""
383
+ for file_info, line in zip(lines, lines[len(lines) // 2 :]):
384
+ change_type = file_info.split("\t")[0][-1]
384
385
  (insertions, deletions, filename) = line.split("\t")
385
- text2 += "%s\t%s\t%s\n" % (insertions, deletions, filename)
386
- text = text2
386
+ text += "%s\t%s\t%s\t%s\n" % (change_type, insertions, deletions, filename)
387
+ return text
388
+
389
+ if not self.parents:
390
+ lines = self.repo.git.diff_tree(
391
+ self.hexsha, "--", numstat=True, no_renames=True, root=True, raw=True
392
+ ).splitlines()[1:]
393
+ text = process_lines(lines)
387
394
  else:
388
- text = self.repo.git.diff(self.parents[0].hexsha, self.hexsha, "--", numstat=True, no_renames=True)
395
+ lines = self.repo.git.diff(
396
+ self.parents[0].hexsha, self.hexsha, "--", numstat=True, no_renames=True, raw=True
397
+ ).splitlines()
398
+ text = process_lines(lines)
389
399
  return Stats._list_from_string(self.repo, text)
390
400
 
391
401
  @property
git/objects/tag.py CHANGED
@@ -14,7 +14,7 @@ __all__ = ["TagObject"]
14
14
  import sys
15
15
 
16
16
  from git.compat import defenc
17
- from git.util import hex_to_bin
17
+ from git.util import Actor, hex_to_bin
18
18
 
19
19
  from . import base
20
20
  from .util import get_object_type_by_name, parse_actor_and_date
@@ -30,7 +30,6 @@ else:
30
30
 
31
31
  if TYPE_CHECKING:
32
32
  from git.repo import Repo
33
- from git.util import Actor
34
33
 
35
34
  from .blob import Blob
36
35
  from .commit import Commit
@@ -64,7 +63,7 @@ class TagObject(base.Object):
64
63
  binsha: bytes,
65
64
  object: Union[None, base.Object] = None,
66
65
  tag: Union[None, str] = None,
67
- tagger: Union[None, "Actor"] = None,
66
+ tagger: Union[None, Actor] = None,
68
67
  tagged_date: Union[int, None] = None,
69
68
  tagger_tz_offset: Union[int, None] = None,
70
69
  message: Union[str, None] = None,
git/objects/util.py CHANGED
@@ -568,11 +568,11 @@ class Traversable(Protocol):
568
568
  yield rval
569
569
 
570
570
  # Only continue to next level if this is appropriate!
571
- nd = d + 1
572
- if depth > -1 and nd > depth:
571
+ next_d = d + 1
572
+ if depth > -1 and next_d > depth:
573
573
  continue
574
574
 
575
- addToStack(stack, item, branch_first, nd)
575
+ addToStack(stack, item, branch_first, next_d)
576
576
  # END for each item on work stack
577
577
 
578
578
 
git/refs/head.py CHANGED
@@ -99,8 +99,8 @@ class HEAD(SymbolicReference):
99
99
  if index:
100
100
  mode = "--mixed"
101
101
 
102
- # It appears some git versions declare mixed and paths deprecated.
103
- # See http://github.com/Byron/GitPython/issues#issue/2.
102
+ # Explicit "--mixed" when passing paths is deprecated since git 1.5.4.
103
+ # See https://github.com/gitpython-developers/GitPython/discussions/1876.
104
104
  if paths:
105
105
  mode = None
106
106
  # END special case
git/remote.py CHANGED
@@ -250,7 +250,7 @@ class PushInfo(IterableObj):
250
250
  flags |= cls.NEW_TAG
251
251
  elif "[new branch]" in summary:
252
252
  flags |= cls.NEW_HEAD
253
- # uptodate encoded in control character
253
+ # `uptodate` encoded in control character
254
254
  else:
255
255
  # Fast-forward or forced update - was encoded in control character,
256
256
  # but we parse the old and new commit.
@@ -316,7 +316,7 @@ class FetchInfo(IterableObj):
316
316
  ERROR,
317
317
  ) = [1 << x for x in range(8)]
318
318
 
319
- _re_fetch_result = re.compile(r"^ *(.) (\[[\w \.$@]+\]|[\w\.$@]+) +(.+) -> ([^ ]+)( \(.*\)?$)?")
319
+ _re_fetch_result = re.compile(r"^ *(?:.{0,3})(.) (\[[\w \.$@]+\]|[\w\.$@]+) +(.+) -> ([^ ]+)( \(.*\)?$)?")
320
320
 
321
321
  _flag_map: Dict[flagKeyLiteral, int] = {
322
322
  "!": ERROR,
@@ -828,8 +828,15 @@ class Remote(LazyMixin, IterableObj):
828
828
  name._clear_cache()
829
829
  return name
830
830
 
831
- # `rm` is an alias.
832
- rm = remove
831
+ @classmethod
832
+ def rm(cls, repo: "Repo", name: str) -> str:
833
+ """Alias of remove.
834
+ Remove the remote with the given name.
835
+
836
+ :return:
837
+ The passed remote name to remove
838
+ """
839
+ return cls.remove(repo, name)
833
840
 
834
841
  def rename(self, new_name: str) -> "Remote":
835
842
  """Rename self to the given `new_name`.
@@ -887,7 +894,7 @@ class Remote(LazyMixin, IterableObj):
887
894
  None,
888
895
  progress_handler,
889
896
  finalizer=None,
890
- decode_streams=True,
897
+ decode_streams=False,
891
898
  kill_after_timeout=kill_after_timeout,
892
899
  )
893
900
 
@@ -1064,7 +1071,7 @@ class Remote(LazyMixin, IterableObj):
1064
1071
  Git.check_unsafe_options(options=list(kwargs.keys()), unsafe_options=self.unsafe_git_fetch_options)
1065
1072
 
1066
1073
  proc = self.repo.git.fetch(
1067
- "--", self, *args, as_process=True, with_stdout=False, universal_newlines=False, v=verbose, **kwargs
1074
+ "--", self, *args, as_process=True, with_stdout=False, universal_newlines=True, v=verbose, **kwargs
1068
1075
  )
1069
1076
  res = self._get_fetch_info_from_stderr(proc, progress, kill_after_timeout=kill_after_timeout)
1070
1077
  if hasattr(self.repo.odb, "update_cache"):
@@ -1118,7 +1125,7 @@ class Remote(LazyMixin, IterableObj):
1118
1125
  Git.check_unsafe_options(options=list(kwargs.keys()), unsafe_options=self.unsafe_git_pull_options)
1119
1126
 
1120
1127
  proc = self.repo.git.pull(
1121
- "--", self, refspec, with_stdout=False, as_process=True, universal_newlines=False, v=True, **kwargs
1128
+ "--", self, refspec, with_stdout=False, as_process=True, universal_newlines=True, v=True, **kwargs
1122
1129
  )
1123
1130
  res = self._get_fetch_info_from_stderr(proc, progress, kill_after_timeout=kill_after_timeout)
1124
1131
  if hasattr(self.repo.odb, "update_cache"):
git/repo/base.py CHANGED
@@ -179,7 +179,7 @@ class Repo:
179
179
  R"""Create a new :class:`Repo` instance.
180
180
 
181
181
  :param path:
182
- The path to either the root git directory or the bare git repo::
182
+ The path to either the worktree directory or the .git directory itself::
183
183
 
184
184
  repo = Repo("/Users/mtrier/Development/git-python")
185
185
  repo = Repo("/Users/mtrier/Development/git-python.git")
@@ -402,6 +402,17 @@ class Repo:
402
402
  """
403
403
  return Head.list_items(self)
404
404
 
405
+ @property
406
+ def branches(self) -> "IterableList[Head]":
407
+ """Alias for heads.
408
+ A list of :class:`~git.refs.head.Head` objects representing the branch heads
409
+ in this repo.
410
+
411
+ :return:
412
+ ``git.IterableList(Head, ...)``
413
+ """
414
+ return self.heads
415
+
405
416
  @property
406
417
  def references(self) -> "IterableList[Reference]":
407
418
  """A list of :class:`~git.refs.reference.Reference` objects representing tags,
@@ -412,11 +423,16 @@ class Repo:
412
423
  """
413
424
  return Reference.list_items(self)
414
425
 
415
- # Alias for references.
416
- refs = references
426
+ @property
427
+ def refs(self) -> "IterableList[Reference]":
428
+ """Alias for references.
429
+ A list of :class:`~git.refs.reference.Reference` objects representing tags,
430
+ heads and remote references.
417
431
 
418
- # Alias for heads.
419
- branches = heads
432
+ :return:
433
+ ``git.IterableList(Reference, ...)``
434
+ """
435
+ return self.references
420
436
 
421
437
  @property
422
438
  def index(self) -> "IndexFile":
git/repo/fun.py CHANGED
@@ -112,7 +112,7 @@ def find_submodule_git_dir(d: PathLike) -> Optional[PathLike]:
112
112
  path = content[8:]
113
113
 
114
114
  if Git.is_cygwin():
115
- # Cygwin creates submodules prefixed with `/cygdrive/...` suffixes.
115
+ # Cygwin creates submodules prefixed with `/cygdrive/...`.
116
116
  # Cygwin git understands Cygwin paths much better than Windows ones.
117
117
  # Also the Cygwin tests are assuming Cygwin paths.
118
118
  path = cygpath(path)
git/types.py CHANGED
@@ -248,6 +248,7 @@ class Files_TD(TypedDict):
248
248
  insertions: int
249
249
  deletions: int
250
250
  lines: int
251
+ change_type: str
251
252
 
252
253
 
253
254
  class Total_TD(TypedDict):
git/util.py CHANGED
@@ -339,7 +339,7 @@ def _get_exe_extensions() -> Sequence[str]:
339
339
  if PATHEXT:
340
340
  return tuple(p.upper() for p in PATHEXT.split(os.pathsep))
341
341
  elif sys.platform == "win32":
342
- return (".BAT", "COM", ".EXE")
342
+ return (".BAT", ".COM", ".EXE")
343
343
  else:
344
344
  return ()
345
345
 
@@ -910,6 +910,7 @@ class Stats:
910
910
  deletions = number of deleted lines as int
911
911
  insertions = number of inserted lines as int
912
912
  lines = total number of lines changed as int, or deletions + insertions
913
+ change_type = type of change as str, A|C|D|M|R|T|U|X|B
913
914
 
914
915
  ``full-stat-dict``
915
916
 
@@ -938,7 +939,7 @@ class Stats:
938
939
  "files": {},
939
940
  }
940
941
  for line in text.splitlines():
941
- (raw_insertions, raw_deletions, filename) = line.split("\t")
942
+ (change_type, raw_insertions, raw_deletions, filename) = line.split("\t")
942
943
  insertions = raw_insertions != "-" and int(raw_insertions) or 0
943
944
  deletions = raw_deletions != "-" and int(raw_deletions) or 0
944
945
  hsh["total"]["insertions"] += insertions
@@ -949,6 +950,7 @@ class Stats:
949
950
  "insertions": insertions,
950
951
  "deletions": deletions,
951
952
  "lines": insertions + deletions,
953
+ "change_type": change_type,
952
954
  }
953
955
  hsh["files"][filename.strip()] = files_dict
954
956
  return Stats(hsh["total"], hsh["files"])