Now that whole_file and no_whole_file are separate variables, have the
[rsync/rsync.git] / util.c
diff --git a/util.c b/util.c
index 63073bd..c1e0471 100644 (file)
--- a/util.c
+++ b/util.c
@@ -84,6 +84,26 @@ int fd_pair(int fd[2])
 }
 
 
+static void print_child_argv(char **cmd)
+{
+       rprintf(FINFO, "opening connection using ");
+       for (; *cmd; cmd++) {
+               /* Look for characters that ought to be quoted.  This
+               * is not a great quoting algorithm, but it's
+               * sufficient for a log message. */
+               if (strspn(*cmd, "abcdefghijklmnopqrstuvwxyz"
+                          "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+                          "0123456789"
+                          ",.-_=+@/") != strlen(*cmd)) {
+                       rprintf(FINFO, "\"%s\" ", *cmd);
+               } else {
+                       rprintf(FINFO, "%s ", *cmd);
+               }
+       }
+       rprintf(FINFO, "\n");
+}
+
+
 /* this is derived from CVS code 
 
    note that in the child STDIN is set to blocking and STDOUT
@@ -100,6 +120,10 @@ pid_t piped_child(char **command, int *f_in, int *f_out)
        int to_child_pipe[2];
        int from_child_pipe[2];
        extern int blocking_io;
+       
+       if (verbose >= 2) {
+               print_child_argv(command);
+       }
 
        if (fd_pair(to_child_pipe) < 0 || fd_pair(from_child_pipe) < 0) {
                rprintf(FERROR, "pipe: %s\n", strerror(errno));
@@ -216,10 +240,18 @@ void overflow(char *str)
 
 
 
-int set_modtime(char *fname,time_t modtime)
+int set_modtime(char *fname, time_t modtime)
 {
        extern int dry_run;
-       if (dry_run) return 0;
+       if (dry_run)
+               return 0;
+
+       if (verbose > 2) {
+               rprintf(FINFO, "set modtime of %s to (%ld) %s",
+                       fname, (long) modtime,
+                       asctime(localtime(&modtime)));
+       }
+       
        {
 #ifdef HAVE_UTIMBUF
                struct utimbuf tbuf;  
@@ -535,7 +567,7 @@ static void glob_expand_one(char *s, char **argv, int *argc, int maxargs)
                globfree(&globbuf);
                return;
        }
-       for (i=0; i<(maxargs - (*argc)) && i<globbuf.gl_pathc;i++) {
+       for (i=0; i<(maxargs - (*argc)) && i < (int) globbuf.gl_pathc;i++) {
                if (i == 0) free(argv[*argc]);
                argv[(*argc) + i] = strdup(globbuf.gl_pathv[i]);
                if (!argv[(*argc) + i]) out_of_memory("glob_expand");
@@ -834,7 +866,14 @@ static void rprint_progress(OFF_T ofs, OFF_T size, struct timeval *now,
     unsigned long diff = msdiff(&start_time, now);
     double        rate = diff ? (double) (ofs-start_ofs) * 1000.0 / diff / 1024.0 : 0;
     const char    *units;
-    double        remain = rate ? (double) (size-ofs) / rate / 1000.0: 0.0;
+    /* If we've finished transferring this file, show the time taken;
+     * otherwise show expected time to complete.  That's kind of
+     * inconsistent, but people can probably cope.  Hopefully we'll
+     * get more consistent and complete progress reporting soon. --
+     * mbp */
+    double        remain = is_last
+                        ? (double) diff / 1000.0
+                        : rate ? (double) (size-ofs) / rate / 1000.0 : 0.0;
     int          remain_h, remain_m, remain_s;
 
     if (rate > 1024*1024) {