extern int verbose;
extern int dry_run;
+extern int itemize_changes;
extern int relative_paths;
extern int keep_dirlinks;
extern int preserve_links;
return 1;
}
+
+#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)
+
+static void showchg(const char *fname, struct file_struct *file, int statret,
+ STRUCT_STAT *st, int flags)
+{
+ static char ch[] = "*XcstpogDL";
+ int keep_time;
+ char *s;
+
+ ch[0] = flags & SC_SENDING_FILE ? '*' : ' ';
+ ch[1] = S_ISDIR(file->mode) ? 'd' : IS_DEVICE(file->mode) ? 'D'
+ : S_ISLNK(file->mode) ? 'L' : 'f';
+
+ if (statret < 0) {
+ for (s = ch + 2; *s; ) *s++ = '+';
+ goto print_it;
+ }
+
+ keep_time = !preserve_times ? 0
+ : S_ISDIR(file->mode) ? !omit_dir_times : !S_ISLNK(file->mode);
+
+ 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'
+ : !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)
+ 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, safe_fname(fname),
+ ch[1] == 'd' ? "/" : "",
+ flags & SC_NO_NL ? "" : "\n");
+ }
+}
+
+
/* Perform our quick-check heuristic for determining if a file is unchanged. */
static int unchanged_file(char *fn, struct file_struct *file, STRUCT_STAT *st)
{
unmap_file(mapbuf);
}
+
/* Try to find a filename in the same dir as "fname" with a similar name. */
static int find_fuzzy(struct file_struct *file, struct file_list *dirlist)
{
missing_below = file->dir.depth;
dry_run++;
}
+ 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
|| create_directory_path(fname, orig_umask) < 0
}
}
if (set_perms(fname, file, statret ? NULL : &st, 0)
- && verbose && f_out != -1)
+ && 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))
delete_in_dir(flist, fname, file);
return;
- } else if (max_size && file->length > max_size) {
+ }
+
+ if (max_size && file->length > max_size) {
if (verbose > 1) {
rprintf(FINFO, "%s is over max-size\n",
safe_fname(fname));
* right place -- no further action
* required. */
if (strcmp(lnk, file->u.link) == 0) {
+ if (itemize_changes)
+ showchg(fname, file, 0, &st, 0);
set_perms(fname, file, &st,
PERMS_REPORT);
return;
full_fname(fname), safe_fname(file->u.link));
} else {
set_perms(fname,file,NULL,0);
+ if (itemize_changes) {
+ showchg(fname, file, statret, &st,
+ SC_SYMLINK_CHANGED
+ | (verbose ? SC_NO_NL : 0));
+ }
if (verbose) {
- rprintf(FINFO, "%s -> %s\n", safe_fname(fname),
- safe_fname(file->u.link));
+ rprintf(FINFO, "%s -> %s\n",
+ itemize_changes ? "" : safe_fname(fname),
+ safe_fname(file->u.link));
}
}
#endif
}
if (am_root && preserve_devices && IS_DEVICE(file->mode)) {
+ if (itemize_changes)
+ showchg(fname, file, statret, &st, 0);
if (statret != 0 ||
st.st_mode != file->mode ||
st.st_rdev != file->u.rdev) {
full_fname(fname));
} else {
set_perms(fname,file,NULL,0);
- if (verbose) {
+ if (verbose && !itemize_changes) {
rprintf(FINFO, "%s\n",
safe_fname(fname));
}
fnamecmp = fname;
fnamecmp_type = FNAMECMP_FNAME;
- if (statret == -1 && basis_dir[0] != NULL) {
+ if (statret != 0 && basis_dir[0] != NULL) {
int fallback_match = -1;
int match_level = 0;
int i = 0;
if (partial_dir && (partialptr = partial_dir_fname(fname)) != NULL
&& link_stat(partialptr, &partial_st, 0) == 0
&& S_ISREG(partial_st.st_mode)) {
- if (statret == -1)
+ if (statret != 0)
goto prepare_to_open;
} else
partialptr = NULL;
- if (statret == -1 && fuzzy_basis && dry_run <= 1) {
+ if (statret != 0 && fuzzy_basis && dry_run <= 1) {
int j = find_fuzzy(file, fuzzy_dirlist);
if (j >= 0) {
fuzzy_file = fuzzy_dirlist->files[j];
}
}
- if (statret == -1) {
+ if (statret != 0) {
if (preserve_hard_links && hard_link_check(file, HL_SKIP))
return;
if (stat_errno == ENOENT)
else if (fnamecmp_type == FNAMECMP_FUZZY)
;
else if (unchanged_file(fnamecmp, file, &st)) {
+ if (itemize_changes) {
+ showchg(fname, file, statret, &st,
+ fnamecmp_type == FNAMECMP_FNAME ? 0
+ : SC_NO_BASIS);
+ }
if (fnamecmp_type == FNAMECMP_FNAME)
set_perms(fname, file, &st, PERMS_REPORT);
return;
if (dry_run || read_batch)
goto notify_others;
if (whole_file > 0) {
- statret = -1;
+ if (statret == 0)
+ statret = 1;
goto notify_others;
}
write_buf(f_out_name, fuzzy_file->basename, len);
}
}
+ if (itemize_changes) {
+ showchg(fname, file, statret, &st,
+ (always_checksum ? SC_CHECKSUM_CHANGED : 0)
+ | SC_SENDING_FILE);
+ }
if (dry_run || read_batch)
return;