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