Make 'svn add --force /path/to/wc-root' work as expected. * subversion/libsvn_client/add.c (svn_client_add4): Check the to-be-added path to see if it's a working copy root. If so, we know it's under version control so --force is required to go further. We also know that we can't get a WC lock on its parent, so adjust our locking parameters accordingly. Index: subversion/libsvn_client/add.c =================================================================== --- subversion/libsvn_client/add.c (revision 1394552) +++ subversion/libsvn_client/add.c (working copy) @@ -671,6 +671,7 @@ const char *parent_abspath; const char *local_abspath; const char *existing_parent_abspath; + svn_boolean_t is_wc_root; if (svn_path_is_url(path)) return svn_error_createf(SVN_ERR_ILLEGAL_TARGET, NULL, @@ -678,6 +679,17 @@ SVN_ERR(svn_dirent_get_absolute(&local_abspath, path, pool)); + /* See if we're being asked to add a wc-root. That's typically not + okay, unless we're in "force" mode. */ + SVN_ERR(svn_wc_is_wc_root2(&is_wc_root, ctx->wc_ctx, + local_abspath, pool)); + if (is_wc_root && (! force)) + { + return svn_error_createf(SVN_ERR_ENTRY_EXISTS, NULL, + _("'%s' is already under version control"), + svn_dirent_local_style(local_abspath, pool)); + } + /* ### this is a hack. ### before we switched to absolute paths, if a user tried to do ### 'svn add .', PATH would be "" and PARENT_PATH would also be "", @@ -708,7 +720,9 @@ add(local_abspath, depth, force, no_ignore, existing_parent_abspath, ctx, pool), ctx->wc_ctx, - existing_parent_abspath ? existing_parent_abspath : parent_abspath, + is_wc_root ? local_abspath + : (existing_parent_abspath ? existing_parent_abspath + : parent_abspath), FALSE /* lock_anchor */, pool); return SVN_NO_ERROR; }