git: Show list of pruned references after running git-pack-refs
A follow-up of #5554 (closed)
Gitaly runs git-pack-refs command as a part of housekeeping task. This command packs loose references into a single packed-refs
file. Afterward, it removes all per-file loose references on the disk. This optimization improves ref querying time.
When working on adding housekeeping support to WAL transaction, we encounter a use case where we need to get a list of pruned references. This list is because the point of time git-pack-refs
runs is different from the time the transaction is committed. During the log application process, we traverse the disk and remove the loose refs ourselves. Unfortunately, git-pack-refs
doesn't support this feature. So, we performed two ref walkings before and after running the command. The difference between the two walks is the list of pruned refs. This workaround works but is not performant.
This issue proposes to add one more flag to the git-pack-refs
command to output the list of pruned refs. As a generalization, we can push further for that command to output more information, such as the size of packed-refs to name a few. Some suggested ideas:
git pack-refs --print-pruned
git pack-refs --verbose
Most of the work will be in refs/files-backend.c. I have a poor man's workable POC: