summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Santolaria <xsa@cvs.openbsd.org>2005-03-09 15:24:37 +0000
committerXavier Santolaria <xsa@cvs.openbsd.org>2005-03-09 15:24:37 +0000
commit7e70e915ac07d0d3e239dc13e585bce972530dcd (patch)
tree0f27b9b9cb31a51a96663b6f69eb4af0e4d2a21e
parent95ba38abe551630b2fb6954b9bcf52e3145485bf (diff)
enable -f option of `remove' command; ok jfb joris
-rw-r--r--usr.bin/cvs/remove.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/usr.bin/cvs/remove.c b/usr.bin/cvs/remove.c
index a6bf49e71f3..b3871f3d2a1 100644
--- a/usr.bin/cvs/remove.c
+++ b/usr.bin/cvs/remove.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: remove.c,v 1.2 2005/01/31 16:49:28 jfb Exp $ */
+/* $OpenBSD: remove.c,v 1.3 2005/03/09 15:24:36 xsa Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* Copyright (c) 2004 Xavier Santolaria <xsa@openbsd.org>
@@ -46,6 +46,7 @@ extern char *__progname;
int cvs_remove_file (CVSFILE *, void *);
+int force_remove = 0; /* -f option */
/*
* cvs_remove()
@@ -62,6 +63,7 @@ cvs_remove(int argc, char **argv)
while ((ch = getopt(argc, argv, "flR")) != -1) {
switch (ch) {
case 'f':
+ force_remove = 1;
break;
case 'l':
break;
@@ -151,6 +153,15 @@ cvs_remove_file(CVSFILE *cf, void *arg)
if (ent != NULL)
ret = cvs_sendentry(root, ent);
} else {
+ /* if -f option is used, physically remove the file */
+ if (force_remove == 1) {
+ if((unlink(fpath) == -1) && (errno != ENOENT)) {
+ cvs_log(LP_ERRNO, "failed to unlink `%s'",
+ fpath);
+ return (-1);
+ }
+ }
+
cvs_log(LP_INFO, "scheduling file `%s' for removal",
CVS_FILE_NAME(cf));
cvs_log(LP_INFO,