1. Test case: # touch a b # chmod 777 a; chmod 000 b # ./rsync -vanx a b building file list ... done wrote 54 bytes read 20 bytes 148.00 bytes/sec total size is 0 speedup is 0.00 /* Please note the b does not show up. * Without -n option and with addition -v option (-vv), b does show up. * * The patch provides below does: * (1) with "-n" option, b shows up. * (2) without "-n" option and with only "-v" option b show up as well. * I consider (1) as a bug fix; and (2) makes the rsync behavior more close * to what documented in man page, as attributes are part of a file. * / -v, --verbose This option increases the amount of information you are given during the transfer. By default, rsync works silently. A single -v will give you information about what files are being transferred and a brief summary at the end. Two -v flags will give you information on what files are being skipped and slightly more information at the end. More than two -v flags should only be used if you are debugging rsync. # ./rsync_patched -vanx a b building file list ... done chmod: b wrote 54 bytes read 20 bytes 49.33 bytes/sec total size is 0 speedup is 0.00 2. Patch --- rsync-2.6.2/rsync.c Tue Mar 23 11:16:15 2004 +++ rsync-2.6.2-new/rsync.c Wed Sep 15 01:35:16 2004 @@ -129,7 +129,6 @@ STRUCT_STAT st2; int change_uid, change_gid; - if (dry_run) return 0; if (!st) { if (link_stat(fname,&st2) != 0) { @@ -142,6 +141,10 @@ if (preserve_times && !S_ISLNK(st->st_mode) && cmp_modtime(st->st_mtime, file->modtime) != 0) { + if (dry_run) { + rprintf(FINFO,"modtime: %s\n",fname); + return 0; + } /* don't complain about not setting times on directories * because some filesystems can't do it */ if (set_modtime(fname,file->modtime) != 0 && @@ -157,6 +160,10 @@ change_gid = preserve_gid && file->gid != GID_NONE && st->st_gid != file->gid; if (change_uid || change_gid) { + if (dry_run) { + rprintf(FINFO,"chown: %s\n",fname); + return 0; + } if (verbose > 2) { if (change_uid) { rprintf(FINFO, @@ -191,6 +198,10 @@ #ifdef HAVE_CHMOD if (!S_ISLNK(st->st_mode)) { if ((st->st_mode & CHMOD_BITS) != (file->mode & CHMOD_BITS)) { + if (dry_run) { + rprintf(FINFO,"chmod: %s\n",fname); + return 0; + } updated = 1; if (do_chmod(fname,(file->mode & CHMOD_BITS)) != 0) { rprintf(FERROR, "failed to set permissions on %s : %s\n", @@ -201,7 +212,7 @@ } #endif - if (verbose > 1 && report) { + if (verbose >= 1 && report) { if (updated) rprintf(FINFO,"%s\n",fname); else
Yes, rsync doesn't output filenames that aren't being transferred, so when it just twiddles the attributes of a file (such as the mode or group), it usually does that silently (unless debugging levels of verbosity are used). I'll consider this as an enhancement request for the future. Certainly we want to make better logging possible, but we do need to be careful about chaing the output of the standard verbose mode (which some folks parse in their scripts). Note also that you should attach patches to a bug report rather than pasting it into the comments.
Created attachment 666 [details] patch for rsync.c The patch addresses 2 issues. (1) under dry-run mode, files with attribute changes are not listed even with two -v flags. I consider this as a bug because (a) dry-run mode "will just report the actions it would have taken". Taking off the dry-run mode the files are reported with two -v flags. (b) under dry run mode, the information for files with attribute changes is not available which violates the Freedom of Information Act. (2) List the files with attribute changes with one -v flag. While this is arguable, my side of arguments are (a) attributes are part of a file, it may be as important as, or more important than, the content depending what you do; (b) Man page says "Two -v flags will give you information on what files are being skipped and slightly more information at the end". The current behavior that two -v flags list attribute changes does not agree with documentation. (Wayne's reply addressed issue #2, but not #1). The following is additional enhancement request not addressed by the patch: The better approach, putting aside of the backward compatibility, is to report all the changes, and flag each type of changes with new, delete, content update, permission, owner, group, modification time, what else. This way, people can parse and select what they need. Thank you.
Yes, there is an inconsistency in --dry-run mode with -vv verbosity, but it will be harder to fix than what you proposed. For instance, your fix doesn't handle the case where the directory needs to be created (it would replace the now-silent directory-creation behavior in --dry-run mode with a stat error), it outputs only the first change it finds (there could multiple multiple things that need to be updated), and it introduces a new output syntax into verbose mode that we need to consider carefully (as it affects the scripting of rsync). A better long-term solution is to introduce a configurable logging system that lets the user ask for the type of change information they want to see. These dry-run bugs are not a high priority to fix right now, but will be looked into later on.
The output with -vv and --dry-run now displays whether the files are "uptodate" or not, so you can see which files have changes in group, ownership, or permissions without actually doing the transfer now. Adding one more -v will show you the details of changes in group/ownership, just like non --dry-run mode. The output of --dry-run with only one --verbose option is unchanged -- the current idiom is to only show filenames for files that need to be transferred, and I'm not willing to change that without making it optional.