New version of up to use in the upcomming patch/pullbin. Reference: /n/patches.lsub.org/patch/newup Date: Wed Apr 18 15:53:29 CES 2012 Signed-off-by: nemo@lsub.org Binary files up.orig and up differ --- /sys/src/cmd/up.c Sat Apr 14 23:00:56 2012 +++ /sys/src/cmd/up.c Wed Apr 18 12:41:55 2012 @@ -19,6 +19,7 @@ static int omode = Rc; static char *droot; static Biobuf bout; +static int usemtime; static int realerror(void) @@ -30,6 +31,14 @@ } static int +samemeta(Dir *sd, Dir *dd) +{ + if(dd->mtime > sd->mtime) + return -1; + return sd->length == sd->length && dd->mtime == sd->mtime; +} + +static int samecontent(char *f1, char *f2) { Waitmsg *m; @@ -250,10 +259,21 @@ } if((sd->mode&DMDIR) == 0){ - if(samecontent(src, dst) == 0){ - updatecp(src, dst, 0); - return 0; - } + if(usemtime){ + switch(samemeta(sd, dd)){ + case 0: + updatecp(src, dst, 0); + return 0; + case -1: + Bflush(&bout); + fprint(2, "%s is newer: ignored\n", dst); + return 0; + } + }else + if(samecontent(src, dst) == 0){ + updatecp(src, dst, 0); + return 0; + } if(omode == Chg && (samemode(sd, dd) == 0 || (dogids && strcmp(sd->gid, dd->gid) != 0) || @@ -276,7 +296,7 @@ static void usage(void) { - fprint(2, "usage: %s [-cugs] src dst\n", argv0); + fprint(2, "usage: %s [-cutgs] src dst\n", argv0); exits("usage"); } @@ -286,6 +306,9 @@ Dir *sd, *dd; ARGBEGIN{ + case 't': + usemtime = 1; + break; case 'c': omode = Chg; break; --- /sys/man/1/up Sat Apr 14 22:46:33 2012 +++ /sys/man/1/up Wed Apr 18 12:49:29 2012 @@ -4,7 +4,7 @@ .SH SYNOPSIS .B up [ -.B -cugs +.B -cugst ] .I src .I dst @@ -45,6 +45,13 @@ and .I dst differ. +.PP +Flag +.B -t +relies on the file length and modification time to guess if two +files are the same or differ. Under this flag, no update is reported +for files that exist both in the destination and the origin and are +newer in the destination. .SH SOURCE .B /sys/src/cmd/up.c .SH EXAMPLE