Don't use the result of "diff" if just sending the new file would be shorter
authortholo <tholo@openbsd.org>
Sat, 4 May 1996 07:26:05 +0000 (07:26 +0000)
committertholo <tholo@openbsd.org>
Sat, 4 May 1996 07:26:05 +0000 (07:26 +0000)
gnu/usr.bin/cvs/src/update.c

index 32c4c8c..84d406c 100644 (file)
@@ -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);
        }
     }