Skip to content

Commit

Permalink
Temporarily rename Commit_ish to Old_commit_ish
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
EliahKagan committed Mar 10, 2024
1 parent b9d9e56 commit 04a2753
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 47 deletions.
4 changes: 2 additions & 2 deletions git/index/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
Union,
)

from git.types import Commit_ish, Literal, PathLike
from git.types import Old_commit_ish, Literal, PathLike

if TYPE_CHECKING:
from subprocess import Popen
Expand Down Expand Up @@ -1127,7 +1127,7 @@ def move(
def commit(
self,
message: str,
parent_commits: Union[Commit_ish, None] = None,
parent_commits: Union[Old_commit_ish, None] = None,
head: bool = True,
author: Union[None, "Actor"] = None,
committer: Union[None, "Actor"] = None,
Expand Down
12 changes: 6 additions & 6 deletions git/objects/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

from typing import Any, TYPE_CHECKING, Union

from git.types import PathLike, Commit_ish, Lit_commit_ish
from git.types import PathLike, Old_commit_ish, Lit_old_commit_ish

if TYPE_CHECKING:
from git.repo import Repo
Expand Down Expand Up @@ -53,7 +53,7 @@ class Object(LazyMixin):
* "tag object": https://git-scm.com/docs/gitglossary#def_tag_object
:note:
See the :class:`~git.types.Commit_ish` union type.
See the :class:`~git.types.Old_commit_ish` union type.
:note:
:class:`~git.objects.submodule.base.Submodule` is defined under the hierarchy
Expand All @@ -77,7 +77,7 @@ class Object(LazyMixin):

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

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

def __init__(self, repo: "Repo", binsha: bytes):
Expand All @@ -113,7 +113,7 @@ def __init__(self, repo: "Repo", binsha: bytes):
)

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

@classmethod
def new_from_sha(cls, repo: "Repo", sha1: bytes) -> Commit_ish:
def new_from_sha(cls, repo: "Repo", sha1: bytes) -> Old_commit_ish:
"""
:return:
New object instance of a type appropriate to represent the given binary sha1
Expand Down
16 changes: 8 additions & 8 deletions git/objects/submodule/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
from typing import Callable, Dict, Mapping, Sequence, TYPE_CHECKING, cast
from typing import Any, Iterator, Union

from git.types import Commit_ish, Literal, PathLike, TBD
from git.types import Old_commit_ish, Literal, PathLike, TBD

if TYPE_CHECKING:
from git.index import IndexFile
Expand Down Expand Up @@ -112,7 +112,7 @@ def __init__(
mode: Union[int, None] = None,
path: Union[PathLike, None] = None,
name: Union[str, None] = None,
parent_commit: Union[Commit_ish, None] = None,
parent_commit: Union[Old_commit_ish, None] = None,
url: Union[str, None] = None,
branch_path: Union[PathLike, None] = None,
) -> None:
Expand Down Expand Up @@ -213,7 +213,7 @@ def __repr__(self) -> str:

@classmethod
def _config_parser(
cls, repo: "Repo", parent_commit: Union[Commit_ish, None], read_only: bool
cls, repo: "Repo", parent_commit: Union[Old_commit_ish, None], read_only: bool
) -> SubmoduleConfigParser:
"""
:return:
Expand Down Expand Up @@ -264,7 +264,7 @@ def _clear_cache(self) -> None:
# END for each name to delete

@classmethod
def _sio_modules(cls, parent_commit: Commit_ish) -> BytesIO:
def _sio_modules(cls, parent_commit: Old_commit_ish) -> BytesIO:
"""
:return:
Configuration file as :class:`~io.BytesIO` - we only access it through the
Expand All @@ -277,7 +277,7 @@ def _sio_modules(cls, parent_commit: Commit_ish) -> BytesIO:
def _config_parser_constrained(self, read_only: bool) -> SectionConstraint:
""":return: Config parser constrained to our submodule in read or write mode"""
try:
pc: Union["Commit_ish", None] = self.parent_commit
pc: Union["Old_commit_ish", None] = self.parent_commit
except ValueError:
pc = None
# END handle empty parent repository
Expand Down Expand Up @@ -1242,7 +1242,7 @@ def remove(

return self

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

@property
def parent_commit(self) -> "Commit_ish":
def parent_commit(self) -> "Old_commit_ish":
"""
:return:
:class:`~git.objects.commit.Commit` instance with the tree containing the
Expand Down Expand Up @@ -1557,7 +1557,7 @@ def children(self) -> IterableList["Submodule"]:
def iter_items(
cls,
repo: "Repo",
parent_commit: Union[Commit_ish, str] = "HEAD",
parent_commit: Union[Old_commit_ish, str] = "HEAD",
*Args: Any,
**kwargs: Any,
) -> Iterator["Submodule"]:
Expand Down
4 changes: 2 additions & 2 deletions git/objects/submodule/root.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from typing import TYPE_CHECKING, Union

from git.types import Commit_ish
from git.types import Old_commit_ish

if TYPE_CHECKING:
from git.repo import Repo
Expand Down Expand Up @@ -77,7 +77,7 @@ def _clear_cache(self) -> None:

def update( # type: ignore[override]
self,
previous_commit: Union[Commit_ish, None] = None,
previous_commit: Union[Old_commit_ish, None] = None,
recursive: bool = True,
force_remove: bool = False,
init: bool = True,
Expand Down
4 changes: 2 additions & 2 deletions git/refs/head.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from typing import Any, Sequence, Union, TYPE_CHECKING

from git.types import PathLike, Commit_ish
from git.types import PathLike, Old_commit_ish

if TYPE_CHECKING:
from git.repo import Repo
Expand Down Expand Up @@ -62,7 +62,7 @@ def orig_head(self) -> SymbolicReference:

def reset(
self,
commit: Union[Commit_ish, SymbolicReference, str] = "HEAD",
commit: Union[Old_commit_ish, SymbolicReference, str] = "HEAD",
index: bool = True,
working_tree: bool = False,
paths: Union[PathLike, Sequence[PathLike], None] = None,
Expand Down
4 changes: 2 additions & 2 deletions git/refs/reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# typing ------------------------------------------------------------------

from typing import Any, Callable, Iterator, Type, Union, TYPE_CHECKING
from git.types import Commit_ish, PathLike, _T
from git.types import Old_commit_ish, PathLike, _T

if TYPE_CHECKING:
from git.repo import Repo
Expand Down Expand Up @@ -81,7 +81,7 @@ def __str__(self) -> str:
# @ReservedAssignment
def set_object(
self,
object: Union[Commit_ish, "SymbolicReference", str],
object: Union[Old_commit_ish, "SymbolicReference", str],
logmsg: Union[str, None] = None,
) -> "Reference":
"""Special version which checks if the head-log needs an update as well.
Expand Down
8 changes: 4 additions & 4 deletions git/refs/symbolic.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
TYPE_CHECKING,
cast,
)
from git.types import Commit_ish, PathLike
from git.types import Old_commit_ish, PathLike

if TYPE_CHECKING:
from git.repo import Repo
Expand Down Expand Up @@ -278,7 +278,7 @@ def _get_ref_info(cls, repo: "Repo", ref_path: Union[PathLike, None]) -> Union[T
"""
return cls._get_ref_info_helper(repo, ref_path)

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

def set_object(
self,
object: Union[Commit_ish, "SymbolicReference", str],
object: Union[Old_commit_ish, "SymbolicReference", str],
logmsg: Union[str, None] = None,
) -> "SymbolicReference":
"""Set the object we point to, possibly dereference our symbolic reference
Expand Down Expand Up @@ -404,7 +404,7 @@ def _get_reference(self) -> "SymbolicReference":

def set_reference(
self,
ref: Union[Commit_ish, "SymbolicReference", str],
ref: Union[Old_commit_ish, "SymbolicReference", str],
logmsg: Union[str, None] = None,
) -> "SymbolicReference":
"""Set ourselves to the given `ref`.
Expand Down
4 changes: 2 additions & 2 deletions git/refs/tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# typing ------------------------------------------------------------------

from typing import Any, Type, Union, TYPE_CHECKING
from git.types import Commit_ish, PathLike
from git.types import Old_commit_ish, PathLike

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

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

@classmethod
Expand Down
10 changes: 5 additions & 5 deletions git/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
overload,
)

from git.types import PathLike, Literal, Commit_ish
from git.types import PathLike, Literal, Old_commit_ish

if TYPE_CHECKING:
from git.repo.base import Repo
Expand Down Expand Up @@ -196,7 +196,7 @@ def __init__(
self.summary = summary

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

@property
Expand Down Expand Up @@ -362,7 +362,7 @@ def __init__(
ref: SymbolicReference,
flags: int,
note: str = "",
old_commit: Union[Commit_ish, None] = None,
old_commit: Union[Old_commit_ish, None] = None,
remote_ref_path: Optional[PathLike] = None,
) -> None:
"""Initialize a new instance."""
Expand All @@ -381,7 +381,7 @@ def name(self) -> str:
return self.ref.name

@property
def commit(self) -> Commit_ish:
def commit(self) -> Old_commit_ish:
""":return: Commit of our remote ref"""
return self.ref.commit

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

# Parse operation string for more info.
# This makes no sense for symbolic refs, but we parse it anyway.
old_commit: Union[Commit_ish, None] = None
old_commit: Union[Old_commit_ish, None] = None
is_tag_operation = False
if "rejected" in operation:
flags |= cls.REJECTED
Expand Down
8 changes: 4 additions & 4 deletions git/repo/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
TBD,
PathLike,
Lit_config_levels,
Commit_ish,
Old_commit_ish,
CallableProgress,
Tree_ish,
assert_never,
Expand Down Expand Up @@ -696,7 +696,7 @@ def config_writer(self, config_level: Lit_config_levels = "repository") -> GitCo
"""
return GitConfigParser(self._get_config_path(config_level), read_only=False, repo=self, merge_includes=False)

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

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

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

res: List[Union[Commit_ish, None]] = []
res: List[Union[Old_commit_ish, None]] = []
try:
lines = self.git.merge_base(*rev, **kwargs).splitlines() # List[str]
except GitCommandError as err:
Expand Down
12 changes: 6 additions & 6 deletions git/repo/fun.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
# Typing ----------------------------------------------------------------------

from typing import Union, Optional, cast, TYPE_CHECKING
from git.types import Commit_ish
from git.types import Old_commit_ish

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

obj: Union[Commit_ish, "Reference", None] = None
obj: Union[Old_commit_ish, "Reference", None] = None
ref = None
output_type = "commit"
start = 0
Expand All @@ -271,7 +271,7 @@ def rev_parse(repo: "Repo", rev: str) -> Union["Commit", "Tag", "Tree", "Blob"]:
if token == "@":
ref = cast("Reference", name_to_object(repo, rev[:start], return_ref=True))
else:
obj = cast(Commit_ish, name_to_object(repo, rev[:start]))
obj = cast(Old_commit_ish, name_to_object(repo, rev[:start]))
# END handle token
# END handle refname
else:
Expand All @@ -296,7 +296,7 @@ def rev_parse(repo: "Repo", rev: str) -> Union["Commit", "Tag", "Tree", "Blob"]:
pass # Default.
elif output_type == "tree":
try:
obj = cast(Commit_ish, obj)
obj = cast(Old_commit_ish, obj)
obj = to_commit(obj).tree
except (AttributeError, ValueError):
pass # Error raised later.
Expand Down Expand Up @@ -369,7 +369,7 @@ def rev_parse(repo: "Repo", rev: str) -> Union["Commit", "Tag", "Tree", "Blob"]:
parsed_to = start
# Handle hierarchy walk.
try:
obj = cast(Commit_ish, obj)
obj = cast(Old_commit_ish, obj)
if token == "~":
obj = to_commit(obj)
for _ in range(num):
Expand Down Expand Up @@ -398,7 +398,7 @@ def rev_parse(repo: "Repo", rev: str) -> Union["Commit", "Tag", "Tree", "Blob"]:

# Still no obj? It's probably a simple name.
if obj is None:
obj = cast(Commit_ish, name_to_object(repo, rev))
obj = cast(Old_commit_ish, name_to_object(repo, rev))
parsed_to = lr
# END handle simple name

Expand Down
Loading

0 comments on commit 04a2753

Please sign in to comment.