Skip to content
Permalink
Browse files

You can ignore folders using ./folder/* or ./folder now

  • Loading branch information
cabello committed Jul 15, 2012
1 parent 6cb0bed commit 13f1ab693ca056698a370c65b8d139faed782261
Showing with 40 additions and 0 deletions.
  1. +36 −0 src/ignore.c
  2. +1 −0 src/ignore.h
  3. +3 −0 src/search.c
@@ -240,3 +240,39 @@ int filename_filter(struct dirent *dir) {

return 1;
}

int filepath_filter(char *filepath) {
int match_pos;
char *pattern = NULL;
int rc = 0;
int i;

if (opts.search_all_files) {
return 1;
}

match_pos = binary_search(filepath, ignore_names, 0, ignore_names_len);
if (match_pos >= 0) {
log_debug("file %s ignored because name matches static pattern %s", filepath, ignore_names[match_pos]);
return 0;
}

for (i = 0; i < ignore_patterns_len; i++) {
pattern = ignore_patterns[i];
if (fnmatch(pattern, filepath, fnmatch_flags) == 0) {
log_debug("file %s ignored because name matches regex pattern %s", filepath, pattern);
return 0;
}
}

if (opts.ackmate_dir_filter != NULL) {
/* we just care about the match, not where the matches are */
rc = pcre_exec(opts.ackmate_dir_filter, NULL, filepath, strlen(filepath), 0, 0, NULL, 0);
if (rc >= 0) {
log_debug("file %s ignored because name matches ackmate dir filter pattern", filepath);
return 0;
}
}

return 1;
}
@@ -20,5 +20,6 @@ void load_svn_ignore_patterns(const char *path, const int path_len);

int ignorefile_filter(struct dirent *dir);
int filename_filter(struct dirent *dir);
int filepath_filter(char *filepath);

#endif
@@ -289,6 +289,9 @@ void search_dir(const pcre *re, const pcre_extra *re_extra, const char* path, co
}

log_debug("dir %s type %i", dir_full_path, dir->d_type);
if ( ! filepath_filter(dir_full_path)) {
goto cleanup;
}

/* TODO: scan files in current dir before going deeper */
if (dir->d_type == DT_DIR) {

0 comments on commit 13f1ab6

Please sign in to comment.
You can’t perform that action at this time.