Author: stsp
Date: Sat Jun 12 15:05:30 2010
New Revision: 954021

URL: http://svn.apache.org/viewvc?rev=954021&view=rev
Log:
Allow overriding the default value of the --extensions option from the
client configuration file.

* subversion/include/svn_client.h
  (svn_client_diff5): Document that the diff_options argument is now
   allowed to be NULL. This allows clients to say "I have no default
   arguments for diff" in an unambiguous way (before this commit,
   the CLI client passed an array with zero elements, and other
   clients probably do the same).

* subversion/include/svn_config.h
  (SVN_CONFIG_OPTION_DIFF_EXTENSIONS): New.

* subversion/libsvn_subr/config_file.c
  (svn_config_ensure): Document the new diff-extensions option.

* subversion/libsvn_client/diff.c
  (set_up_diff_cmd_and_options): If no diff options are provided, check the
   configuration for diff options. If that fails, initialise the options
   to an empty array (the client used to initialise this array but is no
   longer required to do so).

* subversion/svn/log-cmd.c,
  subversion/svn/diff-cmd.c
  (log_entry_receiver, svn_cl__diff): Pass NULL diff_options if none were
   provided on the command line.

Modified:
    subversion/trunk/subversion/include/svn_client.h
    subversion/trunk/subversion/include/svn_config.h
    subversion/trunk/subversion/libsvn_client/diff.c
    subversion/trunk/subversion/libsvn_subr/config_file.c
    subversion/trunk/subversion/svn/diff-cmd.c
    subversion/trunk/subversion/svn/log-cmd.c

Modified: subversion/trunk/subversion/include/svn_client.h
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_client.h?rev=954021&r1=954020&r2=954021&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_client.h (original)
+++ subversion/trunk/subversion/include/svn_client.h Sat Jun 12 15:05:30 2010
@@ -2347,7 +2347,9 @@ svn_client_blame(const char *path_or_url
  *
  * @a diff_options (an array of <tt>const char *</tt>) is used to pass
  * additional command line options to the diff processes invoked to compare
- * files.
+ * files. @a diff_options is alloed to be @c NULL, in which case a value
+ * for this option might still be obtained from the Subversion configuration
+ * file via client context @a ctx.
  *
  * The authentication baton cached in @a ctx is used to communicate with
  * the repository.

Modified: subversion/trunk/subversion/include/svn_config.h
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_config.h?rev=954021&r1=954020&r2=954021&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_config.h (original)
+++ subversion/trunk/subversion/include/svn_config.h Sat Jun 12 15:05:30 2010
@@ -97,6 +97,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_EXTENSIONS           "diff-extensions"
 #define SVN_CONFIG_OPTION_DIFF3_CMD                 "diff3-cmd"
 #define SVN_CONFIG_OPTION_DIFF3_HAS_PROGRAM_ARG     "diff3-has-program-arg"
 #define SVN_CONFIG_OPTION_MERGE_TOOL_CMD            "merge-tool-cmd"

Modified: subversion/trunk/subversion/libsvn_client/diff.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/diff.c?rev=954021&r1=954020&r2=954021&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/diff.c (original)
+++ subversion/trunk/subversion/libsvn_client/diff.c Sat Jun 12 15:05:30 2010
@@ -1742,7 +1742,7 @@ do_diff_summarize(const struct diff_para
 
 
 /* Initialize DIFF_CMD_BATON.diff_cmd and DIFF_CMD_BATON.options,
- * according to OPTIONS and CONFIG.  CONFIG may be null.
+ * according to OPTIONS and CONFIG.  CONFIG and OPTIONS may be null.
  * Allocate the fields in POOL, which should be at least as long-lived
  * as the pool DIFF_CMD_BATON itself is allocated in.
  */
@@ -1753,14 +1753,25 @@ set_up_diff_cmd_and_options(struct diff_
 {
   const char *diff_cmd = NULL;
  
-  /* See if there is a command. */
+  /* See if there is a diff command and/or diff arguments. */
   if (config)
     {
       svn_config_t *cfg = apr_hash_get(config, SVN_CONFIG_CATEGORY_CONFIG,
                                        APR_HASH_KEY_STRING);
       svn_config_get(cfg, &diff_cmd, SVN_CONFIG_SECTION_HELPERS,
                      SVN_CONFIG_OPTION_DIFF_CMD, NULL);
+      if (options == NULL)
+        {
+          const char *diff_extensions;
+          svn_config_get(cfg, &diff_extensions, SVN_CONFIG_SECTION_HELPERS,
+                         SVN_CONFIG_OPTION_DIFF_EXTENSIONS, NULL);
+          if (diff_extensions)
+            options = svn_cstring_split(diff_extensions, " \t\n\r", TRUE, 
pool);
+        }
     }
+
+  if (options == NULL)
+    options = apr_array_make(pool, 0, sizeof(const char *));
  
   if (diff_cmd)
     SVN_ERR(svn_path_cstring_to_utf8(&diff_cmd_baton->diff_cmd, diff_cmd,

Modified: subversion/trunk/subversion/libsvn_subr/config_file.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/config_file.c?rev=954021&r1=954020&r2=954021&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/config_file.c (original)
+++ subversion/trunk/subversion/libsvn_subr/config_file.c Sat Jun 12 15:05:30 
2010
@@ -979,6 +979,11 @@ svn_config_ensure(const char *config_dir
         "###   This will override the compile-time default, which is to use" NL
         "###   Subversion's internal diff implementation."                   NL
         "# diff-cmd = diff_program (diff, gdiff, etc.)"                      NL
+        "### Diff-extensions are arguments passed to an external diff"       NL
+        "### program or to Subversion's internal diff implementation."       NL
+        "### Set diff-extensions to override the default value of the"       NL
+        "### --extensions command line option."                              NL
+        "# diff-extensions = -u -p"                                          NL
         "### Set diff3-cmd to the absolute path of your 'diff3' program."    NL
         "###   This will override the compile-time default, which is to use" NL
         "###   Subversion's internal diff3 implementation."                  NL

Modified: subversion/trunk/subversion/svn/diff-cmd.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/diff-cmd.c?rev=954021&r1=954020&r2=954021&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/diff-cmd.c (original)
+++ subversion/trunk/subversion/svn/diff-cmd.c Sat Jun 12 15:05:30 2010
@@ -161,11 +161,10 @@ svn_cl__diff(apr_getopt_t *os,
   const svn_client_diff_summarize_func_t summarize_func =
     (opt_state->xml ? summarize_xml : summarize_regular);
 
-  /* 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);
+  else
+    options = NULL;
 
   /* Get an apr_file_t representing stdout and stderr, which is where
      we'll have the external 'diff' program print to. */

Modified: subversion/trunk/subversion/svn/log-cmd.c
URL: 
http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/log-cmd.c?rev=954021&r1=954020&r2=954021&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/log-cmd.c (original)
+++ subversion/trunk/subversion/svn/log-cmd.c Sat Jun 12 15:05:30 2010
@@ -282,10 +282,11 @@ log_entry_receiver(void *baton,
         return svn_error_wrap_apr(status, _("Can't open stderr"));
 
       /* Fall back to "" to get options initialized either way. */
-      {
-        const char *optstr = lb->diff_extensions ? lb->diff_extensions : "";
-        diff_options = svn_cstring_split(optstr, " \t\n\r", TRUE, pool);
-      }
+      if (lb->diff_extensions)
+        diff_options = svn_cstring_split(lb->diff_extensions, " \t\n\r", 
+                                         TRUE, pool);
+      else
+        diff_options = NULL;
 
       start_revision.kind = svn_opt_revision_number;
       start_revision.value.number = log_entry->revision - 1;


Reply via email to