You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2013/09/10 16:01:21 UTC
svn commit: r1521491 - /subversion/trunk/subversion/svnauth/svnauth.c
Author: stsp
Date: Tue Sep 10 14:01:21 2013
New Revision: 1521491
URL: http://svn.apache.org/r1521491
Log:
Make 'svnauth' show the path to the configuration area used, and the number
of credentials matched during listing/deletion. And raise an error if no
credentials were matched to make it easier for scripts to tell whether
listing/deletion succeeded.
* subversion/svnauth/svnauth.c
(walk_credentials_baton_t): Add 'matches' counter.
(walk_credentials): Increment 'matches' counter for each matched credential.
(subcommand_list, subcommand_delete): Initialise 'matches' counter to zero
and print information based on it when the operation is done.
Modified:
subversion/trunk/subversion/svnauth/svnauth.c
Modified: subversion/trunk/subversion/svnauth/svnauth.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svnauth/svnauth.c?rev=1521491&r1=1521490&r2=1521491&view=diff
==============================================================================
--- subversion/trunk/subversion/svnauth/svnauth.c (original)
+++ subversion/trunk/subversion/svnauth/svnauth.c Tue Sep 10 14:01:21 2013
@@ -530,6 +530,7 @@ show_cert_failures(const char *failure_s
struct walk_credentials_baton_t
{
+ int matches;
svn_boolean_t list;
svn_boolean_t delete;
svn_boolean_t show_passwords;
@@ -763,6 +764,8 @@ walk_credentials(svn_boolean_t *delete_c
return SVN_NO_ERROR;
}
+ b->matches++;
+
if (b->list)
SVN_ERR(list_credential(cred_kind, realmstring, sorted_cred_items,
b->show_passwords, scratch_pool));
@@ -786,6 +789,7 @@ subcommand_list(apr_getopt_t *os, void *
const char *config_path;
struct walk_credentials_baton_t b;
+ b.matches = 0;
b.show_passwords = opt_state->show_passwords;
b.list = TRUE;
b.delete = FALSE;
@@ -797,6 +801,34 @@ subcommand_list(apr_getopt_t *os, void *
SVN_ERR(svn_config_walk_auth_data(config_path, walk_credentials, &b,
pool));
+
+ if (b.matches == 0)
+ {
+ if (b.patterns->nelts == 0)
+ SVN_ERR(svn_cmdline_printf(pool,
+ _("Credentials cache in '%s' is empty\n"),
+ svn_dirent_local_style(config_path, pool)));
+ else
+ return svn_error_createf(SVN_ERR_ILLEGAL_TARGET, 0,
+ _("Credentials cache in '%s' contains "
+ "no matching credentials"),
+ svn_dirent_local_style(config_path, pool));
+ }
+ else
+ {
+ if (b.patterns->nelts == 0)
+ SVN_ERR(svn_cmdline_printf(pool,
+ _("Credentials cache in '%s' contains %d "
+ "credentials\n"),
+ svn_dirent_local_style(config_path, pool),
+ b.matches));
+ else
+ SVN_ERR(svn_cmdline_printf(pool,
+ _("Credentials cache in '%s' contains %d "
+ "matching credentials\n"),
+ svn_dirent_local_style(config_path, pool),
+ b.matches));
+ }
return SVN_NO_ERROR;
}
@@ -808,6 +840,7 @@ subcommand_delete(apr_getopt_t *os, void
const char *config_path;
struct walk_credentials_baton_t b;
+ b.matches = 0;
b.show_passwords = opt_state->show_passwords;
b.list = FALSE;
b.delete = TRUE;
@@ -819,6 +852,16 @@ subcommand_delete(apr_getopt_t *os, void
SVN_ERR(svn_config_walk_auth_data(config_path, walk_credentials, &b, pool));
+ if (b.matches == 0)
+ return svn_error_createf(SVN_ERR_ILLEGAL_TARGET, 0,
+ _("Credentials cache in '%s' contains "
+ "no matching credentials"),
+ svn_dirent_local_style(config_path, pool));
+ else
+ SVN_ERR(svn_cmdline_printf(pool, _("Removed %d matching credentials "
+ "from '%s'\n"), b.matches,
+ svn_dirent_local_style(config_path, pool)));
+
return SVN_NO_ERROR;
}