subversion-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Sperling <s...@elego.de>
Subject Re: [PATCH] Reject checkouts to existing directory
Date Wed, 12 Oct 2016 14:36:31 GMT
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)

Mime
View raw message