Skip to content

Commit 04a2753

Browse files
committed
Temporarily rename Commit_ish to Old_commit_ish
And Lit_commit_ish to Lit_old_commit_ish. This is temporary, and only for purposes of bookkeeping while this type is split into two types. Specifically, Old_commit_ish will go away soon, because each occurrence of it will be changed to one of: - A newly redefined Commit_ish union of types representing only git object types that are sometimes commit-ish. - A newly introduced union (using some name formerly not used in GitPython) of all four types representing git object types, the same types as the old Commit_ish, here renamed Old_commit_ish, had overbroadly covered. - Perhaps in some cases something else. For context, see gitpython-developers#1858 (including comments), and comments in gitpython-developers#1859.
1 parent b9d9e56 commit 04a2753

File tree

12 files changed

+47
-47
lines changed

12 files changed

+47
-47
lines changed

git/index/base.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
Union,
8181
)
8282

83-
from git.types import Commit_ish, Literal, PathLike
83+
from git.types import Old_commit_ish, Literal, PathLike
8484

8585
if TYPE_CHECKING:
8686
from subprocess import Popen
@@ -1127,7 +1127,7 @@ def move(
11271127
def commit(
11281128
self,
11291129
message: str,
1130-
parent_commits: Union[Commit_ish, None] = None,
1130+
parent_commits: Union[Old_commit_ish, None] = None,
11311131
head: bool = True,
11321132
author: Union[None, "Actor"] = None,
11331133
committer: Union[None, "Actor"] = None,

git/objects/base.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
from typing import Any, TYPE_CHECKING, Union
1818

19-
from git.types import PathLike, Commit_ish, Lit_commit_ish
19+
from git.types import PathLike, Old_commit_ish, Lit_old_commit_ish
2020

2121
if TYPE_CHECKING:
2222
from git.repo import Repo
@@ -53,7 +53,7 @@ class Object(LazyMixin):
5353
* "tag object": https://git-scm.com/docs/gitglossary#def_tag_object
5454
5555
:note:
56-
See the :class:`~git.types.Commit_ish` union type.
56+
See the :class:`~git.types.Old_commit_ish` union type.
5757
5858
:note:
5959
:class:`~git.objects.submodule.base.Submodule` is defined under the hierarchy
@@ -77,7 +77,7 @@ class Object(LazyMixin):
7777

7878
__slots__ = ("repo", "binsha", "size")
7979

80-
type: Union[Lit_commit_ish, None] = None
80+
type: Union[Lit_old_commit_ish, None] = None
8181
"""String identifying (a concrete :class:`Object` subtype for) a git object type.
8282
8383
The subtypes that this may name correspond to the kinds of git objects that exist,
@@ -90,7 +90,7 @@ class Object(LazyMixin):
9090
``None`` in concrete leaf subclasses representing specific git object types.
9191
9292
:note:
93-
See also :class:`~git.types.Commit_ish`.
93+
See also :class:`~git.types.Old_commit_ish`.
9494
"""
9595

9696
def __init__(self, repo: "Repo", binsha: bytes):
@@ -113,7 +113,7 @@ def __init__(self, repo: "Repo", binsha: bytes):
113113
)
114114

115115
@classmethod
116-
def new(cls, repo: "Repo", id: Union[str, "Reference"]) -> Commit_ish:
116+
def new(cls, repo: "Repo", id: Union[str, "Reference"]) -> Old_commit_ish:
117117
"""
118118
:return:
119119
New :class:`Object` instance of a type appropriate to the object type behind
@@ -130,7 +130,7 @@ def new(cls, repo: "Repo", id: Union[str, "Reference"]) -> Commit_ish:
130130
return repo.rev_parse(str(id))
131131

132132
@classmethod
133-
def new_from_sha(cls, repo: "Repo", sha1: bytes) -> Commit_ish:
133+
def new_from_sha(cls, repo: "Repo", sha1: bytes) -> Old_commit_ish:
134134
"""
135135
:return:
136136
New object instance of a type appropriate to represent the given binary sha1

git/objects/submodule/base.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
from typing import Callable, Dict, Mapping, Sequence, TYPE_CHECKING, cast
4646
from typing import Any, Iterator, Union
4747

48-
from git.types import Commit_ish, Literal, PathLike, TBD
48+
from git.types import Old_commit_ish, Literal, PathLike, TBD
4949

5050
if TYPE_CHECKING:
5151
from git.index import IndexFile
@@ -112,7 +112,7 @@ def __init__(
112112
mode: Union[int, None] = None,
113113
path: Union[PathLike, None] = None,
114114
name: Union[str, None] = None,
115-
parent_commit: Union[Commit_ish, None] = None,
115+
parent_commit: Union[Old_commit_ish, None] = None,
116116
url: Union[str, None] = None,
117117
branch_path: Union[PathLike, None] = None,
118118
) -> None:
@@ -213,7 +213,7 @@ def __repr__(self) -> str:
213213

214214
@classmethod
215215
def _config_parser(
216-
cls, repo: "Repo", parent_commit: Union[Commit_ish, None], read_only: bool
216+
cls, repo: "Repo", parent_commit: Union[Old_commit_ish, None], read_only: bool
217217
) -> SubmoduleConfigParser:
218218
"""
219219
:return:
@@ -264,7 +264,7 @@ def _clear_cache(self) -> None:
264264
# END for each name to delete
265265

266266
@classmethod
267-
def _sio_modules(cls, parent_commit: Commit_ish) -> BytesIO:
267+
def _sio_modules(cls, parent_commit: Old_commit_ish) -> BytesIO:
268268
"""
269269
:return:
270270
Configuration file as :class:`~io.BytesIO` - we only access it through the
@@ -277,7 +277,7 @@ def _sio_modules(cls, parent_commit: Commit_ish) -> BytesIO:
277277
def _config_parser_constrained(self, read_only: bool) -> SectionConstraint:
278278
""":return: Config parser constrained to our submodule in read or write mode"""
279279
try:
280-
pc: Union["Commit_ish", None] = self.parent_commit
280+
pc: Union["Old_commit_ish", None] = self.parent_commit
281281
except ValueError:
282282
pc = None
283283
# END handle empty parent repository
@@ -1242,7 +1242,7 @@ def remove(
12421242

12431243
return self
12441244

1245-
def set_parent_commit(self, commit: Union[Commit_ish, None], check: bool = True) -> "Submodule":
1245+
def set_parent_commit(self, commit: Union[Old_commit_ish, None], check: bool = True) -> "Submodule":
12461246
"""Set this instance to use the given commit whose tree is supposed to
12471247
contain the ``.gitmodules`` blob.
12481248
@@ -1495,7 +1495,7 @@ def url(self) -> str:
14951495
return self._url
14961496

14971497
@property
1498-
def parent_commit(self) -> "Commit_ish":
1498+
def parent_commit(self) -> "Old_commit_ish":
14991499
"""
15001500
:return:
15011501
:class:`~git.objects.commit.Commit` instance with the tree containing the
@@ -1557,7 +1557,7 @@ def children(self) -> IterableList["Submodule"]:
15571557
def iter_items(
15581558
cls,
15591559
repo: "Repo",
1560-
parent_commit: Union[Commit_ish, str] = "HEAD",
1560+
parent_commit: Union[Old_commit_ish, str] = "HEAD",
15611561
*Args: Any,
15621562
**kwargs: Any,
15631563
) -> Iterator["Submodule"]:

git/objects/submodule/root.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
from typing import TYPE_CHECKING, Union
1414

15-
from git.types import Commit_ish
15+
from git.types import Old_commit_ish
1616

1717
if TYPE_CHECKING:
1818
from git.repo import Repo
@@ -77,7 +77,7 @@ def _clear_cache(self) -> None:
7777

7878
def update( # type: ignore[override]
7979
self,
80-
previous_commit: Union[Commit_ish, None] = None,
80+
previous_commit: Union[Old_commit_ish, None] = None,
8181
recursive: bool = True,
8282
force_remove: bool = False,
8383
init: bool = True,

git/refs/head.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
from typing import Any, Sequence, Union, TYPE_CHECKING
1919

20-
from git.types import PathLike, Commit_ish
20+
from git.types import PathLike, Old_commit_ish
2121

2222
if TYPE_CHECKING:
2323
from git.repo import Repo
@@ -62,7 +62,7 @@ def orig_head(self) -> SymbolicReference:
6262

6363
def reset(
6464
self,
65-
commit: Union[Commit_ish, SymbolicReference, str] = "HEAD",
65+
commit: Union[Old_commit_ish, SymbolicReference, str] = "HEAD",
6666
index: bool = True,
6767
working_tree: bool = False,
6868
paths: Union[PathLike, Sequence[PathLike], None] = None,

git/refs/reference.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# typing ------------------------------------------------------------------
1212

1313
from typing import Any, Callable, Iterator, Type, Union, TYPE_CHECKING
14-
from git.types import Commit_ish, PathLike, _T
14+
from git.types import Old_commit_ish, PathLike, _T
1515

1616
if TYPE_CHECKING:
1717
from git.repo import Repo
@@ -81,7 +81,7 @@ def __str__(self) -> str:
8181
# @ReservedAssignment
8282
def set_object(
8383
self,
84-
object: Union[Commit_ish, "SymbolicReference", str],
84+
object: Union[Old_commit_ish, "SymbolicReference", str],
8585
logmsg: Union[str, None] = None,
8686
) -> "Reference":
8787
"""Special version which checks if the head-log needs an update as well.

git/refs/symbolic.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
TYPE_CHECKING,
3232
cast,
3333
)
34-
from git.types import Commit_ish, PathLike
34+
from git.types import Old_commit_ish, PathLike
3535

3636
if TYPE_CHECKING:
3737
from git.repo import Repo
@@ -278,7 +278,7 @@ def _get_ref_info(cls, repo: "Repo", ref_path: Union[PathLike, None]) -> Union[T
278278
"""
279279
return cls._get_ref_info_helper(repo, ref_path)
280280

281-
def _get_object(self) -> Commit_ish:
281+
def _get_object(self) -> Old_commit_ish:
282282
"""
283283
:return:
284284
The object our ref currently refers to. Refs can be cached, they will always
@@ -345,7 +345,7 @@ def set_commit(
345345

346346
def set_object(
347347
self,
348-
object: Union[Commit_ish, "SymbolicReference", str],
348+
object: Union[Old_commit_ish, "SymbolicReference", str],
349349
logmsg: Union[str, None] = None,
350350
) -> "SymbolicReference":
351351
"""Set the object we point to, possibly dereference our symbolic reference
@@ -404,7 +404,7 @@ def _get_reference(self) -> "SymbolicReference":
404404

405405
def set_reference(
406406
self,
407-
ref: Union[Commit_ish, "SymbolicReference", str],
407+
ref: Union[Old_commit_ish, "SymbolicReference", str],
408408
logmsg: Union[str, None] = None,
409409
) -> "SymbolicReference":
410410
"""Set ourselves to the given `ref`.

git/refs/tag.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# typing ------------------------------------------------------------------
1616

1717
from typing import Any, Type, Union, TYPE_CHECKING
18-
from git.types import Commit_ish, PathLike
18+
from git.types import Old_commit_ish, PathLike
1919

2020
if TYPE_CHECKING:
2121
from git.repo import Repo
@@ -82,7 +82,7 @@ def tag(self) -> Union["TagObject", None]:
8282

8383
# Make object read-only. It should be reasonably hard to adjust an existing tag.
8484
@property
85-
def object(self) -> Commit_ish: # type: ignore[override]
85+
def object(self) -> Old_commit_ish: # type: ignore[override]
8686
return Reference._get_object(self)
8787

8888
@classmethod

git/remote.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
overload,
4242
)
4343

44-
from git.types import PathLike, Literal, Commit_ish
44+
from git.types import PathLike, Literal, Old_commit_ish
4545

4646
if TYPE_CHECKING:
4747
from git.repo.base import Repo
@@ -196,7 +196,7 @@ def __init__(
196196
self.summary = summary
197197

198198
@property
199-
def old_commit(self) -> Union[str, SymbolicReference, Commit_ish, None]:
199+
def old_commit(self) -> Union[str, SymbolicReference, Old_commit_ish, None]:
200200
return self._old_commit_sha and self._remote.repo.commit(self._old_commit_sha) or None
201201

202202
@property
@@ -362,7 +362,7 @@ def __init__(
362362
ref: SymbolicReference,
363363
flags: int,
364364
note: str = "",
365-
old_commit: Union[Commit_ish, None] = None,
365+
old_commit: Union[Old_commit_ish, None] = None,
366366
remote_ref_path: Optional[PathLike] = None,
367367
) -> None:
368368
"""Initialize a new instance."""
@@ -381,7 +381,7 @@ def name(self) -> str:
381381
return self.ref.name
382382

383383
@property
384-
def commit(self) -> Commit_ish:
384+
def commit(self) -> Old_commit_ish:
385385
""":return: Commit of our remote ref"""
386386
return self.ref.commit
387387

@@ -438,7 +438,7 @@ def _from_line(cls, repo: "Repo", line: str, fetch_line: str) -> "FetchInfo":
438438

439439
# Parse operation string for more info.
440440
# This makes no sense for symbolic refs, but we parse it anyway.
441-
old_commit: Union[Commit_ish, None] = None
441+
old_commit: Union[Old_commit_ish, None] = None
442442
is_tag_operation = False
443443
if "rejected" in operation:
444444
flags |= cls.REJECTED

git/repo/base.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
TBD,
5656
PathLike,
5757
Lit_config_levels,
58-
Commit_ish,
58+
Old_commit_ish,
5959
CallableProgress,
6060
Tree_ish,
6161
assert_never,
@@ -696,7 +696,7 @@ def config_writer(self, config_level: Lit_config_levels = "repository") -> GitCo
696696
"""
697697
return GitConfigParser(self._get_config_path(config_level), read_only=False, repo=self, merge_includes=False)
698698

699-
def commit(self, rev: Union[str, Commit_ish, None] = None) -> Commit:
699+
def commit(self, rev: Union[str, Old_commit_ish, None] = None) -> Commit:
700700
"""The :class:`~git.objects.commit.Commit` object for the specified revision.
701701
702702
:param rev:
@@ -772,7 +772,7 @@ def iter_commits(
772772

773773
return Commit.iter_items(self, rev, paths, **kwargs)
774774

775-
def merge_base(self, *rev: TBD, **kwargs: Any) -> List[Union[Commit_ish, None]]:
775+
def merge_base(self, *rev: TBD, **kwargs: Any) -> List[Union[Old_commit_ish, None]]:
776776
R"""Find the closest common ancestor for the given revision
777777
(:class:`~git.objects.commit.Commit`\s, :class:`~git.refs.tag.Tag`\s,
778778
:class:`~git.refs.reference.Reference`\s, etc.).
@@ -797,7 +797,7 @@ def merge_base(self, *rev: TBD, **kwargs: Any) -> List[Union[Commit_ish, None]]:
797797
raise ValueError("Please specify at least two revs, got only %i" % len(rev))
798798
# END handle input
799799

800-
res: List[Union[Commit_ish, None]] = []
800+
res: List[Union[Old_commit_ish, None]] = []
801801
try:
802802
lines = self.git.merge_base(*rev, **kwargs).splitlines() # List[str]
803803
except GitCommandError as err:

git/repo/fun.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
# Typing ----------------------------------------------------------------------
2626

2727
from typing import Union, Optional, cast, TYPE_CHECKING
28-
from git.types import Commit_ish
28+
from git.types import Old_commit_ish
2929

3030
if TYPE_CHECKING:
3131
from git.types import PathLike
@@ -249,7 +249,7 @@ def rev_parse(repo: "Repo", rev: str) -> Union["Commit", "Tag", "Tree", "Blob"]:
249249
raise NotImplementedError("commit by message search (regex)")
250250
# END handle search
251251

252-
obj: Union[Commit_ish, "Reference", None] = None
252+
obj: Union[Old_commit_ish, "Reference", None] = None
253253
ref = None
254254
output_type = "commit"
255255
start = 0
@@ -271,7 +271,7 @@ def rev_parse(repo: "Repo", rev: str) -> Union["Commit", "Tag", "Tree", "Blob"]:
271271
if token == "@":
272272
ref = cast("Reference", name_to_object(repo, rev[:start], return_ref=True))
273273
else:
274-
obj = cast(Commit_ish, name_to_object(repo, rev[:start]))
274+
obj = cast(Old_commit_ish, name_to_object(repo, rev[:start]))
275275
# END handle token
276276
# END handle refname
277277
else:
@@ -296,7 +296,7 @@ def rev_parse(repo: "Repo", rev: str) -> Union["Commit", "Tag", "Tree", "Blob"]:
296296
pass # Default.
297297
elif output_type == "tree":
298298
try:
299-
obj = cast(Commit_ish, obj)
299+
obj = cast(Old_commit_ish, obj)
300300
obj = to_commit(obj).tree
301301
except (AttributeError, ValueError):
302302
pass # Error raised later.
@@ -369,7 +369,7 @@ def rev_parse(repo: "Repo", rev: str) -> Union["Commit", "Tag", "Tree", "Blob"]:
369369
parsed_to = start
370370
# Handle hierarchy walk.
371371
try:
372-
obj = cast(Commit_ish, obj)
372+
obj = cast(Old_commit_ish, obj)
373373
if token == "~":
374374
obj = to_commit(obj)
375375
for _ in range(num):
@@ -398,7 +398,7 @@ def rev_parse(repo: "Repo", rev: str) -> Union["Commit", "Tag", "Tree", "Blob"]:
398398

399399
# Still no obj? It's probably a simple name.
400400
if obj is None:
401-
obj = cast(Commit_ish, name_to_object(repo, rev))
401+
obj = cast(Old_commit_ish, name_to_object(repo, rev))
402402
parsed_to = lr
403403
# END handle simple name
404404

0 commit comments

Comments
 (0)