diff options
author | Alexander Potashev <aspotashev@gmail.com> | 2009-01-10 15:07:50 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2009-01-11 13:21:57 -0800 |
commit | 8ca12c0d62c0be4a4987c4a936467ea2a92e915a (patch) | |
tree | 42b4cafd04bbbdfa90a38b6a49396cd3b06a97db /dir.c | |
parent | c123b7c5fb596d93cd015645212c379fc3c381d5 (diff) | |
download | git-8ca12c0d62c0be4a4987c4a936467ea2a92e915a.tar.gz |
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>
Diffstat (limited to 'dir.c')
-rw-r--r-- | dir.c | 12 |
1 files changed, 4 insertions, 8 deletions
@@ -585,10 +585,8 @@ static int read_directory_recursive(struct dir_struct *dir, const char *path, co int len, dtype; int exclude; - if ((de->d_name[0] == '.') && - (de->d_name[1] == 0 || - !strcmp(de->d_name + 1, ".") || - !strcmp(de->d_name + 1, "git"))) + if (is_dot_or_dotdot(de->d_name) || + !strcmp(de->d_name, ".git")) continue; len = strlen(de->d_name); /* Ignore overly long pathnames! */ @@ -793,10 +791,8 @@ int remove_dir_recursively(struct strbuf *path, int only_empty) len = path->len; while ((e = readdir(dir)) != NULL) { struct stat st; - if ((e->d_name[0] == '.') && - ((e->d_name[1] == 0) || - ((e->d_name[1] == '.') && e->d_name[2] == 0))) - continue; /* "." and ".." */ + if (is_dot_or_dotdot(e->d_name)) + continue; strbuf_setlen(path, len); strbuf_addstr(path, e->d_name); |