From: Junio C Hamano Date: Thu, 22 Jan 2009 00:51:03 +0000 (-0800) Subject: Merge branch 'rs/ctype' X-Git-Tag: v1.6.2-rc0~107 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/d9fde065bd808fbbad3b53e10e160c8f8193b577?ds=inline;hp=-c Merge branch 'rs/ctype' * rs/ctype: Add is_regex_special() Change NUL char handling of isspecial() Reformat ctype.c Add ctype test Conflicts: Makefile --- d9fde065bd808fbbad3b53e10e160c8f8193b577 diff --combined Makefile index fa6c51c0e9,20ba65d1e6..270b223adb --- a/Makefile +++ b/Makefile @@@ -1357,6 -1357,7 +1357,7 @@@ endi ### Testing rules TEST_PROGRAMS += test-chmtime$X + TEST_PROGRAMS += test-ctype$X TEST_PROGRAMS += test-date$X TEST_PROGRAMS += test-delta$X TEST_PROGRAMS += test-genrandom$X @@@ -1376,6 -1377,8 +1377,8 @@@ export NO_SVN_TEST test: all $(MAKE) -C t/ all + test-ctype$X: ctype.o + test-date$X: date.o ctype.o test-delta$X: diff-delta.o patch-delta.o @@@ -1441,12 -1444,10 +1444,12 @@@ endi { $(RM) "$$execdir/git-add$X" && \ ln git-add$X "$$execdir/git-add$X" 2>/dev/null || \ cp git-add$X "$$execdir/git-add$X"; } && \ - { $(foreach p,$(filter-out git-add$X,$(BUILT_INS)), $(RM) "$$execdir/$p" && \ - ln "$$execdir/git-add$X" "$$execdir/$p" 2>/dev/null || \ - ln -s "git-add$X" "$$execdir/$p" 2>/dev/null || \ - cp "$$execdir/git-add$X" "$$execdir/$p" || exit;) } && \ + { for p in $(filter-out git-add$X,$(BUILT_INS)); do \ + $(RM) "$$execdir/$$p" && \ + ln "$$execdir/git-add$X" "$$execdir/$$p" 2>/dev/null || \ + ln -s "git-add$X" "$$execdir/$$p" 2>/dev/null || \ + cp "$$execdir/git-add$X" "$$execdir/$$p" || exit; \ + done } && \ ./check_bindir "z$$bindir" "z$$execdir" "$$bindir/git-add$X" install-doc: diff --combined dir.c index 7c598296a9,7ae1e2e75c..d55a41a5ab --- a/dir.c +++ b/dir.c @@@ -75,7 -75,7 +75,7 @@@ static int match_one(const char *match for (;;) { unsigned char c1 = *match; unsigned char c2 = *name; - if (isspecial(c1)) + if (c1 == '\0' || is_glob_special(c1)) break; if (c1 != c2) return 0; @@@ -585,8 -585,10 +585,8 @@@ static int read_directory_recursive(str 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! */ @@@ -678,7 -680,7 +678,7 @@@ static int simple_length(const char *ma for (;;) { unsigned char c = *match++; len++; - if (isspecial(c)) + if (c == '\0' || is_glob_special(c)) return len; } } @@@ -777,25 -779,6 +777,25 @@@ int is_inside_dir(const char *dir return get_relative_cwd(buffer, sizeof(buffer), dir) != NULL; } +int is_empty_dir(const char *path) +{ + DIR *dir = opendir(path); + struct dirent *e; + int ret = 1; + + if (!dir) + return 0; + + while ((e = readdir(dir)) != NULL) + if (!is_dot_or_dotdot(e->d_name)) { + ret = 0; + break; + } + + closedir(dir); + return ret; +} + int remove_dir_recursively(struct strbuf *path, int only_empty) { DIR *dir = opendir(path->buf); @@@ -810,8 -793,10 +810,8 @@@ 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);