From 41a9dd24e46c4823d4a13051449bbfb09864a8e7 Mon Sep 17 00:00:00 2001 From: Ulf Lilleengen Date: Sun, 23 Nov 2008 16:44:49 +0000 Subject: [PATCH] - Make sure comparisons are done on file types as well. - Handle the case where a repository may have been copied, and the symlinks have not been preserved. CVSup removes the files and creates the symlinks, so enable this behaviour in csup as well. - While there, fix comments and style issues. --- contrib/csup/fattr.c | 16 ++++++++++++++++ contrib/csup/updater.c | 14 ++++++-------- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/contrib/csup/fattr.c b/contrib/csup/fattr.c index c8409b6ef86e..b141c2c855d4 100644 --- a/contrib/csup/fattr.c +++ b/contrib/csup/fattr.c @@ -840,6 +840,19 @@ fattr_install(struct fattr *fa, const char *topath, const char *frompath) } #endif + /* + * If it is changed from a file to a symlink, remove the file + * and create the symlink. + */ + if (inplace && (fa->type == FT_SYMLINK) && + (old->type == FT_FILE)) { + error = unlink(topath); + if (error) + goto bad; + error = symlink(fa->linktarget, topath); + if (error) + goto bad; + } /* Determine whether we need to remove the target first. */ if (!inplace && (fa->type == FT_DIRECTORY) != (old->type == FT_DIRECTORY)) { @@ -919,6 +932,9 @@ fattr_equal(const struct fattr *fa1, const struct fattr *fa2) mask = fa1->mask & fa2->mask; if (fa1->type == FT_UNKNOWN || fa2->type == FT_UNKNOWN) return (0); + if (mask & FA_FILETYPE) + if (fa1->type != fa2->type) + return (0); if (mask & FA_MODTIME) if (fa1->modtime != fa2->modtime) return (0); diff --git a/contrib/csup/updater.c b/contrib/csup/updater.c index ef2aba345dee..ea73548fc1c1 100644 --- a/contrib/csup/updater.c +++ b/contrib/csup/updater.c @@ -1255,13 +1255,13 @@ updater_diff_apply(struct updater *up, struct file_update *fup, char *state) /* Update or create a node. */ static int -updater_updatenode(struct updater *up, struct coll *coll, struct file_update *fup, char *name, - char *attr) +updater_updatenode(struct updater *up, struct coll *coll, + struct file_update *fup, char *name, char *attr) { struct fattr *fa, *fileattr; struct status *st; struct statusrec *sr; - int error, issymlink, rv; + int error, rv; sr = &fup->srbuf; st = fup->st; @@ -1270,10 +1270,8 @@ updater_updatenode(struct updater *up, struct coll *coll, struct file_update *fu if (fattr_type(fa) == FT_SYMLINK) { lprintf(1, " Symlink %s -> %s\n", name, fattr_getlinktarget(fa)); - issymlink = 1; } else { lprintf(1, " Mknod %s\n", name); - issymlink = 0; } /* Create directory. */ @@ -1281,11 +1279,11 @@ updater_updatenode(struct updater *up, struct coll *coll, struct file_update *fu if (error) return (UPDATER_ERR_PROTO); - /* If it exists, update attributes. */ + /* If it does not exist, create it. */ if (access(fup->destpath, F_OK) != 0) fattr_makenode(fa, fup->destpath); - - /* + + /* * Coming from attic? I don't think this is a problem since we have * determined attic before we call this function (Look at UpdateNode in * cvsup).