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