X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/06a1dbad61f2560b206a9e0c0e4e46b01a063f13..0cc279e0d367b71e86b372ddd8f9ba499a968196:/generator.c diff --git a/generator.c b/generator.c index 1777ef22..6cbba4ed 100644 --- a/generator.c +++ b/generator.c @@ -25,7 +25,7 @@ extern int verbose; extern int dry_run; -extern int what_has_changed; +extern int itemize_changes; extern int relative_paths; extern int keep_dirlinks; extern int preserve_links; @@ -82,19 +82,18 @@ static int unchanged_attrs(struct file_struct *file, STRUCT_STAT *st) #define SC_CHECKSUM_CHANGED (1<<0) -#define SC_SYMLINK_CHANGED (1<<1) -#define SC_SENDING_FILE (1<<2) -#define SC_NO_BASIS (1<<3) -#define SC_NO_NL (1<<4) +#define SC_UPDATING (1<<1) +#define SC_NO_DEST_AND_NO_UPDATE (1<<2) +#define SC_SKIP_NL (1<<3) static void showchg(const char *fname, struct file_struct *file, int statret, STRUCT_STAT *st, int flags) { - static char ch[] = "*XcstpogDL"; + static char ch[] = "*Xcstpog"; int keep_time; char *s; - ch[0] = flags & SC_SENDING_FILE ? '*' : ' '; + ch[0] = flags & SC_UPDATING ? '*' : ' '; ch[1] = S_ISDIR(file->mode) ? 'd' : IS_DEVICE(file->mode) ? 'D' : S_ISLNK(file->mode) ? 'L' : 'f'; @@ -108,26 +107,25 @@ static void showchg(const char *fname, struct file_struct *file, int statret, ch[2] = !(flags & SC_CHECKSUM_CHANGED) ? '-' : 'c'; ch[3] = !S_ISREG(file->mode) || file->length == st->st_size ? '-' : 's'; - ch[4] = flags & SC_SENDING_FILE && !keep_time ? 'T' + ch[4] = flags & SC_UPDATING && !keep_time ? 'T' : !keep_time || file->modtime == st->st_mtime ? '-' : 't'; ch[5] = !preserve_perms || file->mode == st->st_mode ? '-' : 'p'; ch[6] = !am_root || !preserve_uid || file->uid == st->st_uid ? '-' : 'o'; ch[7] = preserve_gid && file->gid != GID_NONE && st->st_gid != file->gid ? 'g' : '-'; - ch[8] = IS_DEVICE(file->mode) && file->u.rdev != st->st_rdev ? 'D' : '-'; - ch[9] = flags & SC_SYMLINK_CHANGED ? 'L' : '-'; - if (flags & SC_NO_BASIS) + if (flags & SC_NO_DEST_AND_NO_UPDATE) ch[4] = ch[5] = ch[6] = ch[7] = '-'; - s = ch + 2; - if (!(flags & SC_SENDING_FILE)) - while (*s == '-') s++; - if (*s) { - print_it: - rprintf(FINFO, "%s %s%s%s", ch, fname, - ch[1] == 'd' ? "/" : "", - flags & SC_NO_NL ? "" : "\n"); + if (!(flags & SC_UPDATING)) { + for (s = ch + 2; *s == '-'; s++) {} + if (!*s) + return; } + + print_it: + rprintf(FINFO, "%s %s%s%s", ch, safe_fname(fname), + ch[1] == 'd' ? "/" : "", + flags & SC_SKIP_NL ? "" : "\n"); } @@ -447,7 +445,7 @@ static void recv_generator(char *fname, struct file_list *flist, missing_below = file->dir.depth; dry_run++; } - if (what_has_changed && f_out != -1) + if (itemize_changes && f_out != -1) showchg(fname, file, statret, &st, 0); if (statret != 0 && do_mkdir(fname,file->mode) != 0 && errno != EEXIST) { if (!relative_paths || errno != ENOENT @@ -459,7 +457,7 @@ static void recv_generator(char *fname, struct file_list *flist, } } if (set_perms(fname, file, statret ? NULL : &st, 0) - && verbose && f_out != -1 && !what_has_changed) + && verbose && f_out != -1 && !itemize_changes) rprintf(FINFO, "%s/\n", safe_fname(fname)); if (delete_during && f_out != -1 && csum_length != SUM_LENGTH && (file->flags & FLAG_DEL_HERE)) @@ -498,7 +496,7 @@ static void recv_generator(char *fname, struct file_list *flist, * right place -- no further action * required. */ if (strcmp(lnk, file->u.link) == 0) { - if (what_has_changed) + if (itemize_changes) showchg(fname, file, 0, &st, 0); set_perms(fname, file, &st, PERMS_REPORT); @@ -514,14 +512,14 @@ static void recv_generator(char *fname, struct file_list *flist, full_fname(fname), safe_fname(file->u.link)); } else { set_perms(fname,file,NULL,0); - if (what_has_changed) { + if (itemize_changes) { showchg(fname, file, statret, &st, - SC_SYMLINK_CHANGED - | (verbose ? SC_NO_NL : 0)); + SC_UPDATING + | (verbose ? SC_SKIP_NL : 0)); } if (verbose) { rprintf(FINFO, "%s -> %s\n", - what_has_changed ? "" : safe_fname(fname), + itemize_changes ? "" : safe_fname(fname), safe_fname(file->u.link)); } } @@ -530,12 +528,12 @@ static void recv_generator(char *fname, struct file_list *flist, } if (am_root && preserve_devices && IS_DEVICE(file->mode)) { - if (what_has_changed) - showchg(fname, file, statret, &st, 0); if (statret != 0 || st.st_mode != file->mode || st.st_rdev != file->u.rdev) { int dflag = S_ISDIR(st.st_mode) ? DEL_DIR : 0; + if (itemize_changes) + showchg(fname, file, statret, &st, SC_UPDATING); delete_file(fname, dflag | DEL_TERSE); if (verbose > 2) { rprintf(FINFO,"mknod(%s,0%o,0x%x)\n", @@ -547,12 +545,14 @@ static void recv_generator(char *fname, struct file_list *flist, full_fname(fname)); } else { set_perms(fname,file,NULL,0); - if (verbose && !what_has_changed) { + if (verbose && !itemize_changes) { rprintf(FINFO, "%s\n", safe_fname(fname)); } } } else { + if (itemize_changes) + showchg(fname, file, statret, &st, 0); set_perms(fname, file, &st, PERMS_REPORT); } return; @@ -690,10 +690,10 @@ static void recv_generator(char *fname, struct file_list *flist, else if (fnamecmp_type == FNAMECMP_FUZZY) ; else if (unchanged_file(fnamecmp, file, &st)) { - if (what_has_changed) { + if (itemize_changes) { showchg(fname, file, statret, &st, fnamecmp_type == FNAMECMP_FNAME ? 0 - : SC_NO_BASIS); + : SC_NO_DEST_AND_NO_UPDATE); } if (fnamecmp_type == FNAMECMP_FNAME) set_perms(fname, file, &st, PERMS_REPORT); @@ -793,10 +793,10 @@ notify_others: write_buf(f_out_name, fuzzy_file->basename, len); } } - if (what_has_changed) { + if (itemize_changes) { showchg(fname, file, statret, &st, (always_checksum ? SC_CHECKSUM_CHANGED : 0) - | SC_SENDING_FILE); + | SC_UPDATING); } if (dry_run || read_batch)