add is_dot_or_dotdot inline function
A new inline function is_dot_or_dotdot is used to check if the directory name is either "." or "..". It returns a non-zero value if the given string is "." or "..". It's applicable to a lot of Git source code. Signed-off-by: Alexander Potashev <aspotashev@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
c123b7c5fb
commit
8ca12c0d62
@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
#include "cache.h"
|
||||
#include "dir.h"
|
||||
#include "builtin.h"
|
||||
#include "parse-options.h"
|
||||
|
||||
@ -21,9 +22,7 @@ static void count_objects(DIR *d, char *path, int len, int verbose,
|
||||
const char *cp;
|
||||
int bad = 0;
|
||||
|
||||
if ((ent->d_name[0] == '.') &&
|
||||
(ent->d_name[1] == 0 ||
|
||||
((ent->d_name[1] == '.') && (ent->d_name[2] == 0))))
|
||||
if (is_dot_or_dotdot(ent->d_name))
|
||||
continue;
|
||||
for (cp = ent->d_name; *cp; cp++) {
|
||||
int ch = *cp;
|
||||
|
||||
Reference in New Issue
Block a user