housekeeping: Skip prune if there are no old objects
The OptimizeRepository()
RPC heuristically executes git-prune(1). The
heuristic we currently use counts the number of loose objects which
exist after having repacked the repository, and, if they exceed a given
threshold, we'll try to remove them. This also causes us to try and
prune objects though in case there are unreachable, but recent objects.
But because unreachable objects don't get packed, and because we only
prune objects older than two weeks, this will in many cases cause us to
execute git-prune(1) without any need.
Improve the heuristic to only prune objects in case there are loose objects which have an mtime older than two weeks. This should in the general case avoid useless prunes, but still detect the case where there is work to be done.
Changelog: performance
Closes #4121 (closed)