diff options
author | Xavier Santolaria <xsa@cvs.openbsd.org> | 2005-08-22 11:17:27 +0000 |
---|---|---|
committer | Xavier Santolaria <xsa@cvs.openbsd.org> | 2005-08-22 11:17:27 +0000 |
commit | f2fbecb6a3aeb65af9ea07aca6f774bca2681c93 (patch) | |
tree | 12c6efe6cfca20c877f18610b92d1f6abcd3da74 /usr.bin/cvs/remove.c | |
parent | 2aa14fb9420b7d35c37e195398aaf01c6f4b15d9 (diff) |
- handle removal of a freshly added file
- fix crash if we specify -f and the file is not on disk anymore
ok joris@.
Diffstat (limited to 'usr.bin/cvs/remove.c')
-rw-r--r-- | usr.bin/cvs/remove.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/usr.bin/cvs/remove.c b/usr.bin/cvs/remove.c index 3f415954717..3e4b8540679 100644 --- a/usr.bin/cvs/remove.c +++ b/usr.bin/cvs/remove.c @@ -1,4 +1,4 @@ -/* $OpenBSD: remove.c,v 1.34 2005/08/12 06:36:14 xsa Exp $ */ +/* $OpenBSD: remove.c,v 1.35 2005/08/22 11:17:26 xsa Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * Copyright (c) 2004, 2005 Xavier Santolaria <xsa@openbsd.org> @@ -26,6 +26,7 @@ */ #include <sys/types.h> +#include <sys/stat.h> #include <errno.h> #include <fcntl.h> @@ -148,8 +149,10 @@ cvs_remove_local(CVSFILE *cf, void *arg) { int existing, l, removed; char buf[MAXPATHLEN], fpath[MAXPATHLEN]; + CVSENTRIES *entf; existing = removed = 0; + entf = (CVSENTRIES *)cf->cf_entry; if (cf->cf_type == DT_DIR) { if (verbosity > 1) @@ -175,8 +178,8 @@ cvs_remove_local(CVSFILE *cf, void *arg) cf->cf_name); return (0); } else if (cf->cf_cvstat == CVS_FST_ADDED) { - - /* XXX scratch it from CVS/Entries */ + if (cvs_ent_remove(entf, cf->cf_name) == -1) + return (CVS_EX_FILE); l = snprintf(buf, sizeof(buf), "%s/%s%s", CVS_PATH_CVSDIR, cf->cf_name, CVS_DESCR_FILE_EXT); @@ -185,6 +188,7 @@ cvs_remove_local(CVSFILE *cf, void *arg) cvs_log(LP_ERRNO, "%s", buf); return (CVS_EX_DATA); } + if (cvs_unlink(buf) == -1) return (CVS_EX_FILE); @@ -235,11 +239,16 @@ cvs_remove_local(CVSFILE *cf, void *arg) static int cvs_remove_file(const char *fpath) { + struct stat st; + /* if -f option is used, physically remove the file */ if (force_remove == 1) { if(cvs_unlink(fpath) == -1) return (-1); nuked++; + } else { + if ((stat(fpath, &st) == -1) && (errno == ENOENT)) + nuked++; } return (0); |