Skip to content

Option to skip packed_refs in iter_items() #1581

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions git/refs/symbolic.py
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,8 @@ def rename(self, new_path: PathLike, force: bool = False) -> "SymbolicReference"

@classmethod
def _iter_items(
cls: Type[T_References], repo: "Repo", common_path: Union[PathLike, None] = None
cls: Type[T_References], repo: "Repo", common_path: Union[PathLike, None] = None,
packed_refs: bool = True
) -> Iterator[T_References]:
if common_path is None:
common_path = cls._common_path_default
Expand All @@ -685,10 +686,11 @@ def _iter_items(
# END for each directory to walk

# read packed refs
for _sha, rela_path in cls._iter_packed_refs(repo):
if rela_path.startswith(str(common_path)):
rela_paths.add(rela_path)
# END relative path matches common path
if packed_refs:
for _sha, rela_path in cls._iter_packed_refs(repo):
if rela_path.startswith(str(common_path)):
rela_paths.add(rela_path)
# END relative path matches common path
# END packed refs reading

# return paths in sorted order
Expand All @@ -704,6 +706,7 @@ def iter_items(
cls: Type[T_References],
repo: "Repo",
common_path: Union[PathLike, None] = None,
packed_refs: bool = True,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Documentation seems to be missing.

*args: Any,
**kwargs: Any,
) -> Iterator[T_References]:
Expand All @@ -723,7 +726,7 @@ def iter_items(

List is lexicographically sorted
The returned objects represent actual subclasses, such as Head or TagReference"""
return (r for r in cls._iter_items(repo, common_path) if r.__class__ == SymbolicReference or not r.is_detached)
return (r for r in cls._iter_items(repo, common_path, packed_refs) if r.__class__ == SymbolicReference or not r.is_detached)

@classmethod
def from_path(cls: Type[T_References], repo: "Repo", path: PathLike) -> T_References:
Expand Down