From e03cfd5630b61dbe1e59139ab32a5889c0d74a79 Mon Sep 17 00:00:00 2001 From: Xavier Santolaria Date: Thu, 19 May 2005 15:31:36 +0000 Subject: correct handling of the -d option; joris ok --- usr.bin/cvs/release.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'usr.bin') diff --git a/usr.bin/cvs/release.c b/usr.bin/cvs/release.c index eaf42e81a9a..6da27247942 100644 --- a/usr.bin/cvs/release.c +++ b/usr.bin/cvs/release.c @@ -1,4 +1,4 @@ -/* $OpenBSD: release.c,v 1.3 2005/05/17 08:16:03 xsa Exp $ */ +/* $OpenBSD: release.c,v 1.4 2005/05/19 15:31:35 xsa Exp $ */ /* * Copyright (c) 2005 Xavier Santolaria * All rights reserved. @@ -129,6 +129,7 @@ cvs_release_dir(CVSFILE *cdir, void *arg) { FILE *fp; int j, l; + char *wdir, cwd[MAXPATHLEN]; char buf[256], cdpath[MAXPATHLEN], dpath[MAXPATHLEN]; char updcmd[MAXPATHLEN]; /* XXX find a better size; malloc()?? */ struct stat st; @@ -160,9 +161,17 @@ cvs_release_dir(CVSFILE *cdir, void *arg) } if (root->cr_method != CVS_METHOD_LOCAL) { + /* XXX kept for compat reason of `cvs update' output */ + /* save current working directory for further use */ + if ((wdir = getcwd(cwd, sizeof(cwd))) == NULL) + cvs_log(LP_ERRNO, "cannot get current dir"); + /* change dir before running the `cvs update' command */ - if (chdir(dpath) == -1) + if (chdir(dpath) == -1) { + cvs_log(LP_ERRNO, "cannot change to dir `%s'", + dpath); return (-1); + } /* construct `cvs update' command */ l = snprintf(updcmd, sizeof(updcmd), "%s %s %s update", @@ -191,6 +200,7 @@ cvs_release_dir(CVSFILE *cdir, void *arg) printf("You have [%d] altered file%s in this " "repository.\n", j, j > 1 ? "s" : ""); + printf("Are you sure you want to release " "%sdirectory `%s': ", dflag ? "(and delete) " : "", dpath); @@ -202,10 +212,17 @@ cvs_release_dir(CVSFILE *cdir, void *arg) return (-1); } + /* change back to original working dir */ + if (chdir(wdir) == -1) { + cvs_log(LP_ERRNO, "cannot change to original " + "working dir `%s'", wdir); + return (-1); + } + if (dflag == 1) { - if (unlink(dpath) == -1) { + if (cvs_remove_dir(dpath) != CVS_EX_OK) { cvs_log(LP_ERRNO, - "deletion of directory %s failed", + "deletion of directory `%s' failed", dpath); return (-1); } -- cgit v1.2.3