[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [PATCH] Reject checkouts to existing directory

From: Stefan Sperling <stsp_at_elego.de>
Date: Wed, 12 Oct 2016 16:36:31 +0200

On Wed, Oct 12, 2016 at 04:28:05PM +0200, Patrick Steinhardt wrote:
> Hi,
>
> attached is a patch to reject checkouts to already existing
> directories when `--force` is not given. This is according to
> `svn co --help`.
>
> [[
> Reject checkout to existing paths without force
>
> * subversion/svn/checkout-cmd.c:
> - (svn_cl__checkout): Reject checkout to existing directory
> without --force
> ]]

Nice catch.
It's odd that the actual behaviour and help string don't line up.

> diff --git a/subversion/svn/checkout-cmd.c b/subversion/svn/checkout-cmd.c
> index 56fd02b..5fda44a 100644
> --- a/subversion/svn/checkout-cmd.c
> +++ b/subversion/svn/checkout-cmd.c
> @@ -155,6 +155,20 @@ svn_cl__checkout(apr_getopt_t *os,
> subpool);
> }
>
> + if (! opt_state->force)
> + {
> + svn_node_kind_t kind;
> +
> + SVN_ERR(svn_io_check_path(target_dir, &kind, subpool));
> +
> + if (kind != svn_node_none)
> + {
> + return svn_error_createf
> + (SVN_ERR_ILLEGAL_TARGET, NULL,
> + _("Rejecting checkout to existing directory '%s'"), target_dir);

At this poing the node kind could be svn_node_file as well.
Perhaps make it say something like "%s already exists" instead?

Does this patch pass 'make check'?

> + }
> + }
> +
> /* Checkout doesn't accept an unspecified revision, so default to
> the peg revision, or to HEAD if there wasn't a peg. */
> if (revision.kind == svn_opt_revision_unspecified)
Received on 2016-10-12 16:36:35 CEST

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.