module documentation
Git garbage collection implementation.
| Class | |
Statistics from garbage collection. |
| Function | find |
Find all reachable objects in the repository. |
| Function | find |
Find all unreachable objects in the repository. |
| Function | garbage |
Run garbage collection on a repository. |
| Function | get |
Read gc.pruneExpire from config and return grace period in seconds. |
| Function | maybe |
Run automatic garbage collection if needed. |
| Function | prune |
Remove unreachable objects from the repository. |
| Function | should |
Check if automatic garbage collection should run. |
| Constant | DEFAULT |
Undocumented |
| Constant | DEFAULT |
Undocumented |
| Constant | DEFAULT |
Undocumented |
def find_reachable_objects(object_store:
BaseObjectStore, refs_container: RefsContainer, include_reflogs: bool = True, progress: Callable[ [ str], None] | None = None) -> set[ ObjectID]:
¶
Find all reachable objects in the repository.
| Parameters | |
objectBaseObjectStore | Object store to search |
refsRefsContainer | Reference container |
includebool | Whether to include reflog entries |
progress:Callable[ | Optional progress callback |
| Returns | |
set[ | Set of reachable object SHAs |
def find_unreachable_objects(object_store:
BaseObjectStore, refs_container: RefsContainer, include_reflogs: bool = True, progress: Callable[ [ str], None] | None = None) -> set[ ObjectID]:
¶
Find all unreachable objects in the repository.
| Parameters | |
objectBaseObjectStore | Object store to search |
refsRefsContainer | Reference container |
includebool | Whether to include reflog entries |
progress:Callable[ | Optional progress callback |
| Returns | |
set[ | Set of unreachable object SHAs |
def garbage_collect(repo:
Repo, auto: bool = False, aggressive: bool = False, prune: bool = True, grace_period: int | None = 1209600, dry_run: bool = False, progress: Callable[ [ str], None] | None = None) -> GCStats:
¶
Run garbage collection on a repository.
| Parameters | |
repo:Repo | Repository to garbage collect |
auto:bool | Whether this is an automatic gc |
aggressive:bool | Whether to use aggressive settings |
prune:bool | Whether to prune unreachable objects |
graceint | None | Grace period for pruning in seconds |
drybool | If True, only report what would be done |
progress:Callable[ | Optional progress callback |
| Returns | |
GCStats | GCStats object with garbage collection statistics |
Read gc.pruneExpire from config and return grace period in seconds.
If gc.pruneExpire is not set, returns the default of 2 weeks.
| Parameters | |
config:Config | Repository configuration |
| Returns | |
int | Grace period in seconds |
| Raises | |
ValueError | If the configured value cannot be parsed |
def prune_unreachable_objects(object_store:
DiskObjectStore, refs_container: RefsContainer, grace_period: int | None = None, dry_run: bool = False, progress: Callable[ [ str], None] | None = None) -> tuple[ set[ ObjectID], int]:
¶
Remove unreachable objects from the repository.
| Parameters | |
objectDiskObjectStore | Object store to prune |
refsRefsContainer | Reference container |
graceint | None | Grace period in seconds (objects newer than this are kept) |
drybool | If True, only report what would be deleted |
progress:Callable[ | Optional progress callback |
| Returns | |
tuple[ | Tuple of (set of pruned object SHAs, total bytes freed) |