/contrib/cvs/src/no_diff.c

https://bitbucket.org/freebsd/freebsd-head/ · C · 101 lines · 61 code · 11 blank · 29 comment · 17 complexity · 9550b22c708f89ebc9311be5897bb61f MD5 · raw file

  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 "cvs.h"
  22. #include <assert.h>
  23. int
  24. No_Difference (finfo, vers)
  25. struct file_info *finfo;
  26. Vers_TS *vers;
  27. {
  28. Node *p;
  29. int ret;
  30. char *ts, *options;
  31. int retcode = 0;
  32. char *tocvsPath;
  33. /* If ts_user is "Is-modified", we can only conclude the files are
  34. different (since we don't have the file's contents). */
  35. if (vers->ts_user != NULL
  36. && strcmp (vers->ts_user, "Is-modified") == 0)
  37. return -1;
  38. if (!vers->srcfile || !vers->srcfile->path)
  39. return (-1); /* different since we couldn't tell */
  40. #ifdef PRESERVE_PERMISSIONS_SUPPORT
  41. /* If special files are in use, then any mismatch of file metadata
  42. information also means that the files should be considered different. */
  43. if (preserve_perms && special_file_mismatch (finfo, vers->vn_user, NULL))
  44. return 1;
  45. #endif
  46. if (vers->entdata && vers->entdata->options)
  47. options = xstrdup (vers->entdata->options);
  48. else
  49. options = xstrdup ("");
  50. tocvsPath = wrap_tocvs_process_file (finfo->file);
  51. retcode = RCS_cmp_file( vers->srcfile, vers->vn_user, (char **)NULL,
  52. (char *)NULL, options,
  53. tocvsPath == NULL ? finfo->file : tocvsPath );
  54. if (retcode == 0)
  55. {
  56. /* no difference was found, so fix the entries file */
  57. ts = time_stamp (finfo->file);
  58. Register (finfo->entries, finfo->file,
  59. vers->vn_user ? vers->vn_user : vers->vn_rcs, ts,
  60. options, vers->tag, vers->date, (char *) 0);
  61. #ifdef SERVER_SUPPORT
  62. if (server_active)
  63. {
  64. /* We need to update the entries line on the client side. */
  65. server_update_entries
  66. (finfo->file, finfo->update_dir, finfo->repository, SERVER_UPDATED);
  67. }
  68. #endif
  69. free (ts);
  70. /* update the entdata pointer in the vers_ts structure */
  71. p = findnode (finfo->entries, finfo->file);
  72. assert (p);
  73. vers->entdata = p->data;
  74. ret = 0;
  75. }
  76. else
  77. ret = 1; /* files were really different */
  78. if (tocvsPath)
  79. {
  80. /* Need to call unlink myself because the noexec variable
  81. * has been set to 1. */
  82. if (trace)
  83. (void) fprintf (stderr, "%s-> unlink (%s)\n",
  84. CLIENT_SERVER_STR, tocvsPath);
  85. if ( CVS_UNLINK (tocvsPath) < 0)
  86. error (0, errno, "could not remove %s", tocvsPath);
  87. }
  88. free (options);
  89. return (ret);
  90. }