1 /* 2 * Copyright (C) 1986-2005 The Free Software Foundation, Inc. 3 * 4 * Portions Copyright (C) 1998-2005 Derek Price, Ximbiot <http://ximbiot.com>, 5 * and others. 6 * 7 * Portions Copyright (C) 1992, Brian Berliner and Jeff Polk 8 * Portions Copyright (C) 1989-1992, Brian Berliner 9 * 10 * You may distribute under the terms of the GNU General Public License as 11 * specified in the README file that comes with the CVS source distribution. 12 * 13 * No Difference 14 * 15 * The user file looks modified judging from its time stamp; however it needn't 16 * be. No_Difference() finds out whether it is or not. If it is not, it 17 * updates the administration. 18 * 19 * returns 0 if no differences are found and non-zero otherwise 20 */ 21 #include <sys/cdefs.h> 22 __RCSID("$NetBSD: no_diff.c,v 1.2 2016/05/17 14:00:09 christos Exp $"); 23 24 #include "cvs.h" 25 #include <assert.h> 26 27 int 28 No_Difference (struct file_info *finfo, Vers_TS *vers) 29 { 30 Node *p; 31 int ret; 32 char *ts, *options; 33 int retcode = 0; 34 char *tocvsPath; 35 36 /* If ts_user is "Is-modified", we can only conclude the files are 37 different (since we don't have the file's contents). */ 38 if (vers->ts_user != NULL 39 && strcmp (vers->ts_user, "Is-modified") == 0) 40 return -1; 41 42 if (!vers->srcfile || !vers->srcfile->path) 43 return (-1); /* different since we couldn't tell */ 44 45 #ifdef PRESERVE_PERMISSIONS_SUPPORT 46 /* If special files are in use, then any mismatch of file metadata 47 information also means that the files should be considered different. */ 48 if (preserve_perms && special_file_mismatch (finfo, vers->vn_user, NULL)) 49 return 1; 50 #endif 51 52 if (vers->entdata && vers->entdata->options) 53 options = xstrdup (vers->entdata->options); 54 else 55 options = xstrdup (""); 56 57 tocvsPath = wrap_tocvs_process_file (finfo->file); 58 retcode = RCS_cmp_file (vers->srcfile, vers->vn_user, NULL, NULL, options, 59 tocvsPath == NULL ? finfo->file : tocvsPath); 60 if (retcode == 0) 61 { 62 /* no difference was found, so fix the entries file */ 63 ts = time_stamp (finfo->file); 64 Register (finfo->entries, finfo->file, 65 vers->vn_user ? vers->vn_user : vers->vn_rcs, ts, 66 options, vers->tag, vers->date, NULL); 67 #ifdef SERVER_SUPPORT 68 if (server_active) 69 { 70 /* We need to update the entries line on the client side. */ 71 server_update_entries (finfo->file, finfo->update_dir, 72 finfo->repository, SERVER_UPDATED); 73 } 74 #endif 75 free (ts); 76 77 /* update the entdata pointer in the vers_ts structure */ 78 p = findnode (finfo->entries, finfo->file); 79 assert (p); 80 vers->entdata = p->data; 81 82 ret = 0; 83 } 84 else 85 ret = 1; /* files were really different */ 86 87 if (tocvsPath) 88 { 89 /* Need to call unlink myself because the noexec variable 90 * has been set to 1. */ 91 TRACE (TRACE_FUNCTION, "unlink (%s)", tocvsPath); 92 if ( CVS_UNLINK (tocvsPath) < 0) 93 error (0, errno, "could not remove %s", tocvsPath); 94 } 95 96 free (options); 97 return ret; 98 } 99