Re: [PATCH 2/2] Use is_pseudo_dir_name everywhere
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jan 9, 2009, 08:33 UTC
- Message-ID
- <7vy6xk280e.fsf@gitster.siamese.dyndns.org>
- In-Reply-To
- <4966FB36.2030409@viscovery.net>
Johannes Sixt <j.sixt@viscovery.net> writes:
Show 12 quoted lines
> Johannes Sixt schrieb: >> Alexander Potashev schrieb: >>> - if ((ent->d_name[0] == '.') && >>> - (ent->d_name[1] == 0 || >>> - ((ent->d_name[1] == '.') && (ent->d_name[2] == 0)))) >>> + if (is_pseudo_dir_name(ent->d_name)) >> >> Nit-pick: When I read the resulting code, then I will have to look up that >> is_pseudo_dir_name() indeed only checks for "." and "..". But if it were >> named is_dot_or_dotdot(), then I would have to do that. > > ... then I would *not* have to do that, of course.
I think the unstated motivation of this choice of the name is to keep the door open to include lost+found and friends to the repertoire, and perhaps to have an isolated place for customization for non-POSIX platforms and for local conventions. It is more like is_uninteresting_dirent_name().
As long as this function is used only to detect and skip "uninteresting" dirent, I think that is not a bad direction.
On the other hand, I am a bit worried about is_empty_dir() abused outside its intended purpose to say "this directory does not have anything interesting". E.g. "Oh, it's empty so we can nuke it":
if (is_empty_dir(dir))
rmdir(dir);even though the current callers do not do something crazy like this (the usual order we do things is rmdir() and then check for errors).