From: tholo Date: Sat, 4 May 1996 07:26:05 +0000 (+0000) Subject: Don't use the result of "diff" if just sending the new file would be shorter X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=a5efd72c1ea322c16fcf4f56c4a28cfa28e9a0cc;p=openbsd Don't use the result of "diff" if just sending the new file would be shorter --- diff --git a/gnu/usr.bin/cvs/src/update.c b/gnu/usr.bin/cvs/src/update.c index 32c4c8c2fec..84d406ccb70 100644 --- a/gnu/usr.bin/cvs/src/update.c +++ b/gnu/usr.bin/cvs/src/update.c @@ -1160,6 +1160,7 @@ patch_file (file, repository, entries, srcfiles, vers_ts, update_dir, int retval = 0; int retcode = 0; int fail; + long file_size; FILE *e; *docheckout = 0; @@ -1259,6 +1260,9 @@ patch_file (file, repository, entries, srcfiles, vers_ts, update_dir, fail = 1; } + fseek(e, 0L, SEEK_END); + file_size = ftell(e); + fclose (e); } } @@ -1303,6 +1307,16 @@ patch_file (file, repository, entries, srcfiles, vers_ts, update_dir, patch can't handle that. */ fail = 1; } + else { + /* + * Don't send a diff if just sending the entire file + * would be smaller + */ + fseek(e, 0L, SEEK_END); + if (file_size < ftell(e)) + fail = 1; + } + fclose (e); } }