[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH] add diff-cmd-args option to [helper] section.

From: Kouhei Sutou <kou_at_cozmixng.org>
Date: 2005-08-11 06:37:36 CEST

Hi,

I want to use 'diff -upN'. I can use this by specifying like
this: 'svn diff --diff-cmd diff -x "-upN"'. But this is
inconvenience. I want to use 'diff -upN' by default.

The attached patch adds 'diff-cmd-args' option to [helper]
section. If the patch is applied and I write the following
settings to my configuration file, I can always use 'diff
-upN' by default.

  [helpers]
  diff-cmd = diff
  diff-cmd-args = -upN

What about this patch?

[[[
Add diff-cmd-args option to [helper] section in
configuration file.

* subversion/include/svn_config.h
  (SVN_CONFIG_OPTION_DIFF_CMD_ARGS): New macro.

* subversion/libsvn_subr/config_file.c
  (svn_config_ensure): Add description for diff-cmd-args
  option.

* subversion/libsvn_client/diff.c
  (diff_content_changed): Use diff-cmd-args option value by
  default.

* subversion/clients/cmdline/diff-cmd.c (svn_cl__diff):
  Don't set up options when extensions argument isn't
  specified.
]]]

Thanks,

--
kou

Index: subversion/include/svn_config.h
===================================================================
--- subversion/include/svn_config.h (revision 15652)
+++ subversion/include/svn_config.h (working copy)
@@ -79,6 +79,7 @@ typedef struct svn_config_t svn_config_t
 #define SVN_CONFIG_SECTION_HELPERS "helpers"
 #define SVN_CONFIG_OPTION_EDITOR_CMD "editor-cmd"
 #define SVN_CONFIG_OPTION_DIFF_CMD "diff-cmd"
+#define SVN_CONFIG_OPTION_DIFF_CMD_ARGS "diff-cmd-args"
 #define SVN_CONFIG_OPTION_DIFF3_CMD "diff3-cmd"
 #define SVN_CONFIG_OPTION_DIFF3_HAS_PROGRAM_ARG "diff3-has-program-arg"
 #define SVN_CONFIG_SECTION_MISCELLANY "miscellany"
Index: subversion/libsvn_subr/config_file.c
===================================================================
--- subversion/libsvn_subr/config_file.c (revision 15652)
+++ subversion/libsvn_subr/config_file.c (working copy)
@@ -1096,6 +1096,10 @@ svn_config_ensure (const char *config_di
         APR_EOL_STR
         "# diff-cmd = diff_program (diff, gdiff, etc.)"
         APR_EOL_STR
+ "### Set the arguments of your 'diff' program."
+ APR_EOL_STR
+ "# diff-cmd-args = diff_program_arguments (-upN, -u -p, -c, etc.)"
+ APR_EOL_STR
         "### Set diff3-cmd to the absolute path of your 'diff3' program."
         APR_EOL_STR
         "### This will override the compile-time default, which is to use"
Index: subversion/libsvn_client/diff.c
===================================================================
--- subversion/libsvn_client/diff.c (revision 15652)
+++ subversion/libsvn_client/diff.c (working copy)
@@ -331,6 +331,7 @@ diff_content_changed (const char *path,
   struct diff_cmd_baton *diff_cmd_baton = diff_baton;
   const char *diff_cmd = NULL;
   const char **args = NULL;
+ const apr_array_header_t *options = diff_cmd_baton->options;
   int nargs, exitcode;
   apr_pool_t *subpool = svn_pool_create (diff_cmd_baton->pool);
   svn_stream_t *os;
@@ -343,15 +344,29 @@ diff_content_changed (const char *path,
   /* Get a stream from our output file. */
   os = svn_stream_from_aprfile(diff_cmd_baton->outfile, subpool);
 
+ if (! options)
+ {
+ const char *opts = NULL;
+ if (diff_cmd_baton->config)
+ {
+ svn_config_t *cfg = apr_hash_get (diff_cmd_baton->config,
+ SVN_CONFIG_CATEGORY_CONFIG,
+ APR_HASH_KEY_STRING);
+ svn_config_get (cfg, &opts, SVN_CONFIG_SECTION_HELPERS,
+ SVN_CONFIG_OPTION_DIFF_CMD_ARGS, NULL);
+ }
+ /* Fall back to "" to get options initialized either way. */
+ options = svn_cstring_split (opts ? opts : "", " \t\n\r", TRUE, subpool);
+ }
+
   /* Assemble any option args. */
- nargs = diff_cmd_baton->options->nelts;
+ nargs = options->nelts;
   if (nargs)
     {
       args = apr_palloc (subpool, nargs * sizeof (char *));
- for (i = 0; i < diff_cmd_baton->options->nelts; i++)
+ for (i = 0; i < options->nelts; i++)
         {
- args[i] =
- ((const char **)(diff_cmd_baton->options->elts))[i];
+ args[i] = ((const char **)(options->elts))[i];
         }
       assert (i == nargs);
     }
@@ -487,12 +502,11 @@ diff_content_changed (const char *path,
       /* We don't currently support any options (well, other than -u, since we
          default to unified diff output anyway), so if we received anything
          other than that it's an error. */
- if (diff_cmd_baton->options)
+ if (options)
         {
- for (i = 0; i < diff_cmd_baton->options->nelts; ++i)
+ for (i = 0; i < options->nelts; ++i)
             {
- const char *arg
- = ((const char **)(diff_cmd_baton->options->elts))[i];
+ const char *arg = ((const char **)(options->elts))[i];
 
               if (strcmp(arg, "-u") == 0)
                 continue;
Index: subversion/clients/cmdline/diff-cmd.c
===================================================================
--- subversion/clients/cmdline/diff-cmd.c (revision 15652)
+++ subversion/clients/cmdline/diff-cmd.c (working copy)
@@ -44,7 +44,7 @@ svn_cl__diff (apr_getopt_t *os,
               apr_pool_t *pool)
 {
   svn_cl__opt_state_t *opt_state = ((svn_cl__cmd_baton_t *) baton)->opt_state;
- apr_array_header_t *options;
+ apr_array_header_t *options = NULL;
   apr_array_header_t *targets;
   apr_file_t *outfile, *errfile;
   apr_status_t status;
@@ -53,11 +53,8 @@ svn_cl__diff (apr_getopt_t *os,
   svn_boolean_t pegged_diff = FALSE;
   int i;
 
- /* Fall back to "" to get options initialized either way. */
- {
- const char *optstr = opt_state->extensions ? opt_state->extensions : "";
- options = svn_cstring_split (optstr, " \t\n\r", TRUE, pool);
- }
+ if (opt_state->extensions)
+ options = svn_cstring_split (opt_state->extensions, " \t\n\r", TRUE, pool);
 
   /* Get an apr_file_t representing stdout and stderr, which is where
      we'll have the external 'diff' program print to. */

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Thu Aug 11 06:38:17 2005

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.