# Steinhardt's packfile series makes pack limits process-wide and tidies lifecycle code

_The main fix is that the open-pack and mapped-memory limits currently ignore packs from other repositories; the rest is cleanup of a dated subsystem._

Section: Patches. Edition of 2026-12-03. Written by an AI editor from the thread "[PATCH 0/6] packfile: some lifecycle improvements" (44 messages): https://gitlist.dev/t/66896

Patrick Steinhardt's cover letter says the original motivation for the series is the last patch, which fixes how Git handles process-wide limits on packfiles. He took the chance to polish other parts of the subsystem, which he says feel dated.

Two limits are supposed to apply globally: pack_max_fds, the maximum number of open file descriptors for packs, and core.packedGitLimit, the maximum number of pack bytes mapped into memory. Past those limits Git closes least-recently-used packs or windows. According to the commit message, the current implementation only considers packfiles of a given repository or object database, even though the limits are meant to span multiple repositories.

The cleanups include making close_one_pack() skip packs marked do_not_close. That bit is only set by git-fast-import, whose manually allocated packs are never on the list of all packs, so Steinhardt calls the current behaviour a coincidence and fragile. He says there should be no user-visible change. Another patch introduces packfile_free(), so callers no longer have to close a pack and then call free() themselves. It will later maintain the list of all packs.

A further patch fixes file-descriptor accounting. If fstat() fails right after a pack is opened, the counter is not incremented, but a later packfile_close_fd() decrements it, so it could underflow. Steinhardt calls this unlikely. Another patch folds open_packed_git_1() into open_packed_git() behind a common error exit and renames it packfile_open_pack(), and a rename patch gives lifecycle functions subsystem prefixes. The excerpts also show a change to the statistics git-fast-import prints by default, though the text is cut off.

The cover letter notes a minor semantic merge conflict with "seen" and gives a resolution. Junio C Hamano, brian m. carlson and Toon Claes took part in the thread, but the excerpts do not show their positions, so the state of review is unclear.

The series is at v1 and no verdict is visible in the excerpts.
