Re: [PATCH] Remove empty ref directories while reading loose refs
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Feb 10, 2012, 19:09 UTC
- Message-ID
- <7v39aiqzda.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <1328891127-17150-1-git-send-email-pclouds@gmail.com>
Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
> I don't think the a few extra rmdir()s from time to time at startup > are going to cause any problems. Making delete_ref() delete empty > directories takes more effort and probably not worth it.
That reads as a very poorly phrased excuse for not solving the problem at the right location. Compared to all the codepaths that want to resolve ref, delete_ref() is run much less often, and it is where the problem you are solving (i.e. directories that have just become unnecessary are not removed) originates, no?
Wouldn't it be just the matter of replacing two unlink_or_warn() calls in delete_ref(), one for cleaning refs/ hierarchy and the other for cleaning logs/ hierarcy, with a new helper that calls unlink_or_warn() and then tries rmdir going upwards until it hits the limit, perhaps using a helper function that refactors dir.c::remove_path() that takes an extra parameter telling it where to stop?