You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ka...@apache.org on 2011/01/03 12:11:50 UTC
svn commit: r1054583 - /subversion/trunk/subversion/svnrdump/svnrdump.c
Author: kameshj
Date: Mon Jan 3 11:11:49 2011
New Revision: 1054583
URL: http://svn.apache.org/viewvc?rev=1054583&view=rev
Log:
Make a mention of '--version' in help command output.
Sanitize 'invalid' options passed after '--version' command.
* subversion/svnrdump/svnrdump.c
(struct opt_baton_t): New member 'version'.
(help_cmd): Now "svnrdump help" would display a better header.
(main) : Sanitize invalid options passed to "svnrdump --version".
Patch by: Prabhu Gnana Sundar <pr...@collab.net>
Suggested by: kameshj
Tweaked by: kameshj
Modified:
subversion/trunk/subversion/svnrdump/svnrdump.c
Modified: subversion/trunk/subversion/svnrdump/svnrdump.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svnrdump/svnrdump.c?rev=1054583&r1=1054582&r2=1054583&view=diff
==============================================================================
--- subversion/trunk/subversion/svnrdump/svnrdump.c (original)
+++ subversion/trunk/subversion/svnrdump/svnrdump.c Mon Jan 3 11:11:49 2011
@@ -159,6 +159,7 @@ typedef struct opt_baton_t {
svn_ra_session_t *session;
const char *url;
svn_boolean_t help;
+ svn_boolean_t version;
svn_opt_revision_t start_revision;
svn_opt_revision_t end_revision;
svn_boolean_t quiet;
@@ -547,6 +548,7 @@ help_cmd(apr_getopt_t *os,
const char *header =
_("general usage: svnrdump SUBCOMMAND URL [-r LOWER[:UPPER]]\n"
"Type 'svnrdump help <subcommand>' for help on a specific subcommand.\n"
+ "Type 'svnrdump --version' to see the program version and RA modules.\n"
"\n"
"Available subcommands:\n");
@@ -747,8 +749,7 @@ main(int argc, const char **argv)
config_dir = opt_arg;
break;
case opt_version:
- SVNRDUMP_ERR(version(argv[0], pool));
- exit(EXIT_SUCCESS);
+ opt_baton->version = TRUE;
break;
case 'h':
opt_baton->help = TRUE;
@@ -785,13 +786,26 @@ main(int argc, const char **argv)
subcommand = svn_opt_get_canonical_subcommand2(svnrdump__cmd_table,
"help");
}
- else
+ if (subcommand == NULL)
{
if (os->ind >= os->argc)
{
- SVNRDUMP_ERR(help_cmd(NULL, NULL, pool));
- svn_pool_destroy(pool);
- exit(EXIT_FAILURE);
+ if (opt_baton->version)
+ {
+ /* Use the "help" subcommand to handle the "--version" option. */
+ static const svn_opt_subcommand_desc2_t pseudo_cmd =
+ { "--version", help_cmd, {0}, "",
+ {opt_version, /* must accept its own option */
+ } };
+ subcommand = &pseudo_cmd;
+ }
+
+ else
+ {
+ SVNRDUMP_ERR(help_cmd(NULL, NULL, pool));
+ svn_pool_destroy(pool);
+ exit(EXIT_FAILURE);
+ }
}
else
{
@@ -812,7 +826,7 @@ main(int argc, const char **argv)
svn_pool_destroy(pool);
exit(EXIT_FAILURE);
}
- }
+ }
}
/* Check that the subcommand wasn't passed any inappropriate options. */
@@ -847,6 +861,13 @@ main(int argc, const char **argv)
}
}
+ if (subcommand && strcmp(subcommand->name, "--version") == 0)
+ {
+ SVNRDUMP_ERR(version(argv[0], pool));
+ svn_pool_destroy(pool);
+ exit(EXIT_SUCCESS);
+ }
+
if (subcommand && strcmp(subcommand->name, "help") == 0)
{
SVNRDUMP_ERR(help_cmd(os, opt_baton, pool));