From d567322fbc4005051e81a6c0bdb25774ac78f402 Mon Sep 17 00:00:00 2001 From: Martin Pool Date: Mon, 9 Oct 2000 03:46:38 +0000 Subject: [PATCH] include/exclude cluestick: with -vv, print out whether files are included or excluded and why. --- exclude.c | 50 +++++++++++++++++++++++++++++++++++++++++--------- flist.c | 4 ++-- rsync.h | 1 - 3 files changed, 43 insertions(+), 12 deletions(-) diff --git a/exclude.c b/exclude.c index 8a1dfe30..6539b0fd 100644 --- a/exclude.c +++ b/exclude.c @@ -20,6 +20,8 @@ /* a lot of this stuff was originally derived from GNU tar, although it has now changed so much that it is hard to tell :) */ +/* include/exclude cluestick added by Martin Pool */ + #include "rsync.h" extern int verbose; @@ -84,8 +86,8 @@ static void free_exclude(struct exclude_struct *ex) free(ex); } -static int check_one_exclude(char *name,struct exclude_struct *ex, - STRUCT_STAT *st) +static int check_one_exclude(char *name, struct exclude_struct *ex, + STRUCT_STAT *st) { char *p; int match_start=0; @@ -121,25 +123,55 @@ static int check_one_exclude(char *name,struct exclude_struct *ex, } -int check_exclude(char *name,struct exclude_struct **local_exclude_list, +static void report_exclude_result(char const *name, + struct exclude_struct const *ent, + STRUCT_STAT const *st) +{ + /* If a trailing slash is present to match only directories, + * then it is stripped out by make_exclude. So as a special + * case we add it back in here. */ + + if (verbose >= 2) + rprintf(FINFO, "%s %s %s because of pattern %s%s\n", + ent->include ? "including" : "excluding", + S_ISDIR(st->st_mode) ? "directory" : "file", + name, ent->pattern, + ent->directory ? "/" : ""); +} + + +/* + * Return true if file NAME is defined to be excluded by either + * LOCAL_EXCLUDE_LIST or the globals EXCLUDE_LIST. + */ +int check_exclude(char *name, struct exclude_struct **local_exclude_list, STRUCT_STAT *st) { int n; + struct exclude_struct const *ent; if (name && (name[0] == '.') && !name[1]) /* never exclude '.', even if somebody does --exclude '*' */ return 0; if (exclude_list) { - for (n=0; exclude_list[n]; n++) - if (check_one_exclude(name,exclude_list[n],st)) - return !exclude_list[n]->include; + for (n=0; exclude_list[n]; n++) { + ent = exclude_list[n]; + if (check_one_exclude(name, ent, st)) { + report_exclude_result(name, ent, st); + return !ent->include; + } + } } if (local_exclude_list) { - for (n=0; local_exclude_list[n]; n++) - if (check_one_exclude(name,local_exclude_list[n],st)) - return !local_exclude_list[n]->include; + for (n=0; local_exclude_list[n]; n++) { + ent = exclude_list[n]; + if (check_one_exclude(name, ent, st)) { + report_exclude_result(name, ent, st); + return !ent->include; + } + } } return 0; diff --git a/flist.c b/flist.c index 4ad30964..1082c400 100644 --- a/flist.c +++ b/flist.c @@ -185,8 +185,6 @@ int link_stat(const char *Path, STRUCT_STAT *Buffer) static int match_file_name(char *fname,STRUCT_STAT *st) { if (check_exclude(fname,local_exclude_list,st)) { - if (verbose > 2) - rprintf(FINFO,"excluding file %s\n",fname); return 0; } return 1; @@ -700,6 +698,8 @@ struct file_list *send_file_list(int f,int argc,char *argv[]) if (verbose && recurse && !am_server && f != -1) { rprintf(FINFO,"building file list ... "); + if (verbose > 1) + rprintf(FINFO, "\n"); rflush(FINFO); } diff --git a/rsync.h b/rsync.h index 588219fe..5f61caae 100644 --- a/rsync.h +++ b/rsync.h @@ -344,7 +344,6 @@ struct map_struct { }; struct exclude_struct { - char *orig; char *pattern; int regular_exp; int fnmatch_flags; -- 2.34.1