2 * propdel-cmd.c -- Remove property from files/dirs
4 * ====================================================================
5 * Licensed to the Apache Software Foundation (ASF) under one
6 * or more contributor license agreements. See the NOTICE file
7 * distributed with this work for additional information
8 * regarding copyright ownership. The ASF licenses this file
9 * to you under the Apache License, Version 2.0 (the
10 * "License"); you may not use this file except in compliance
11 * with the License. You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing,
16 * software distributed under the License is distributed on an
17 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18 * KIND, either express or implied. See the License for the
19 * specific language governing permissions and limitations
21 * ====================================================================
24 /* ==================================================================== */
30 #include "svn_cmdline.h"
31 #include "svn_pools.h"
32 #include "svn_client.h"
33 #include "svn_error_codes.h"
34 #include "svn_error.h"
39 #include "svn_private_config.h"
44 /* This implements the `svn_opt_subcommand_t' interface. */
46 svn_cl__propdel(apr_getopt_t *os,
50 svn_cl__opt_state_t *opt_state = ((svn_cl__cmd_baton_t *) baton)->opt_state;
51 svn_client_ctx_t *ctx = ((svn_cl__cmd_baton_t *) baton)->ctx;
53 apr_array_header_t *args, *targets;
55 /* Get the property's name (and a UTF-8 version of that name). */
56 SVN_ERR(svn_opt_parse_num_args(&args, os, 1, pool));
57 pname = APR_ARRAY_IDX(args, 0, const char *);
58 SVN_ERR(svn_utf_cstring_to_utf8(&pname, pname, pool));
59 /* No need to check svn_prop_name_is_valid for *deleting*
60 properties, and it may even be useful to allow, in case invalid
61 properties sneaked through somehow. */
63 SVN_ERR(svn_cl__args_to_target_array_print_reserved(&targets, os,
68 /* Add "." if user passed 0 file arguments */
69 svn_opt_push_implicit_dot_target(targets, pool);
70 SVN_ERR(svn_cl__eat_peg_revisions(&targets, targets, pool));
72 if (opt_state->revprop) /* operate on a revprop */
77 SVN_ERR(svn_cl__revprop_prepare(&opt_state->start_revision, targets,
80 /* Let libsvn_client do the real work. */
81 SVN_ERR(svn_client_revprop_set2(pname, NULL, NULL,
82 URL, &(opt_state->start_revision),
83 &rev, FALSE, ctx, pool));
85 else if (opt_state->start_revision.kind != svn_opt_revision_unspecified)
87 return svn_error_createf(SVN_ERR_CLIENT_PROPERTY_NAME, NULL,
88 _("Cannot specify revision for deleting versioned property '%s'"),
91 else /* operate on a normal, versioned property (not a revprop) */
93 if (opt_state->depth == svn_depth_unknown)
94 opt_state->depth = svn_depth_empty;
96 /* For each target, remove the property PNAME. */
97 SVN_ERR(svn_client_propset_local(pname, NULL, targets,
98 opt_state->depth, FALSE,
99 opt_state->changelists, ctx, pool));