You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by da...@apache.org on 2010/06/28 12:57:52 UTC

svn commit: r958537 - in /subversion/trunk/subversion: include/svn_diff.h libsvn_client/diff.c libsvn_diff/diff_file.c svn/main.c tests/cmdline/getopt_tests_data/svn_help_log_switch_stdout

Author: dannas
Date: Mon Jun 28 10:57:50 2010
New Revision: 958537

URL: http://svn.apache.org/viewvc?rev=958537&view=rev
Log:
Add a new diff extension flag '--git-diff [-g]' for specifying that
we want to use git's extended diff format.

With the diff format, a delete, copy or move may be described with only a
header.  Non-git-aware patch applications can not process such a patch, thus
the need for a flag to stay backward compatible with our old diff format.

With the flag there are no need for the SVN_EXPERIMENTAL_PATCH ifdefs.

Note: We don't yet create diff headers for copied or moved paths.

* subversion/libsvn_diff/diff_file.c
  (diff_options): Add our new flag.
  (svn_diff_file_options_parse): Add check for our new flag.

* subversion/svn/main.c
  (svn_cl__options): Add text to describe the new flag.

* subversion/include/svn_diff.h
  (svn_diff_file_options_t): Add 'use_git_format' flag.
  (svn_diff_file_options_parse): Add our new flag to the doc 
    string.

* subversion/libsvn_client/diff.c
  (print_git_diff_header_added,
   print_git_diff_header_modified,
   print_git_diff_header_deleted,
   print_git_diff_header_copied,
   print_git_diff_header_moved):  Remove SVN_EXPERIMENTAL_PATCH ifdefs
  (diff_content_changed): Check for 'use_git_format' instead of having
    the parts dealing with git diffs inside SVN_EXPERIMENTAL_PATCH 
    ifdefs.

* subversion/tests/cmdline/getopt_tests_data/svn_help_log_switch_stdout
  (...): Add the help output for our new flag.

Modified:
    subversion/trunk/subversion/include/svn_diff.h
    subversion/trunk/subversion/libsvn_client/diff.c
    subversion/trunk/subversion/libsvn_diff/diff_file.c
    subversion/trunk/subversion/svn/main.c
    subversion/trunk/subversion/tests/cmdline/getopt_tests_data/svn_help_log_switch_stdout

Modified: subversion/trunk/subversion/include/svn_diff.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_diff.h?rev=958537&r1=958536&r2=958537&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_diff.h (original)
+++ subversion/trunk/subversion/include/svn_diff.h Mon Jun 28 10:57:50 2010
@@ -382,6 +382,8 @@ typedef struct svn_diff_file_options_t
     * @c FALSE.
     */
   svn_boolean_t show_c_function;
+  /** Whether to use git's extended diff format. The default is @c FALSE. */
+  svn_boolean_t use_git_format;
 } svn_diff_file_options_t;
 
 /** Allocate a @c svn_diff_file_options_t structure in @a pool, initializing
@@ -403,6 +405,7 @@ svn_diff_file_options_create(apr_pool_t 
  * - --ignore-space-change, -b
  * - --ignore-all-space, -w
  * - --ignore-eol-style
+ * - --git-diff -g.
  * - --unified, -u (for compatibility, does nothing).
  */
 svn_error_t *

Modified: subversion/trunk/subversion/libsvn_client/diff.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/diff.c?rev=958537&r1=958536&r2=958537&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/diff.c (original)
+++ subversion/trunk/subversion/libsvn_client/diff.c Mon Jun 28 10:57:50 2010
@@ -306,8 +306,6 @@ display_prop_diffs(const apr_array_heade
   return SVN_NO_ERROR;
 }
 
-#ifdef SVN_EXPERIMENTAL_PATCH
-
 /*
  * Print a git diff header for PATH to the stream OS using HEADER_ENCODING.
  * All allocations are done in RESULT_POOL. */
@@ -391,7 +389,6 @@ print_git_diff_header_modified(svn_strea
                                       path, path, APR_EOL_STR));
   return SVN_NO_ERROR;
 }
-#endif
 
 /*-----------------------------------------------------------------*/
 
@@ -694,47 +691,48 @@ diff_content_changed(const char *path,
                   (os, diff_cmd_baton->header_encoding, subpool,
                    "Index: %s" APR_EOL_STR "%s" APR_EOL_STR,
                    path, equal_string));
-#ifdef SVN_EXPERIMENTAL_PATCH
-
-          /* Add git headers and adjust the labels. 
-           * ### Once we're using the git format everywhere, we can create
-           * ### one func that sets the correct labels in one place. */
-          if (operation == svn_diff_op_deleted)
+          if (diff_cmd_baton->options.for_internal->use_git_format)
             {
-              SVN_ERR(print_git_diff_header_deleted(
-                                            os, 
-                                            diff_cmd_baton->header_encoding,
-                                            path, subpool));
-              svn_pool_destroy(subpool);
 
-              /* We only display the git diff header for deletes. */
-              return SVN_NO_ERROR;
+              /* Add git headers and adjust the labels. 
+               * ### Once we're using the git format everywhere, we can create
+               * ### one func that sets the correct labels in one place. */
+              if (operation == svn_diff_op_deleted)
+                {
+                  SVN_ERR(print_git_diff_header_deleted(
+                                              os, 
+                                              diff_cmd_baton->header_encoding,
+                                              path, subpool));
+                  svn_pool_destroy(subpool);
+
+                  /* We only display the git diff header for deletes. */
+                  return SVN_NO_ERROR;
+
+                }
+              else if (operation == svn_diff_op_added)
+                {
+                  SVN_ERR(print_git_diff_header_added(
+                                                os, 
+                                                diff_cmd_baton->header_encoding,
+                                                path, subpool));
+                  label1 = diff_label("/dev/null", rev1, subpool);
+                  label2 = diff_label(apr_psprintf(subpool, "b/%s", path2), 
+                                      rev2, subpool);
+                }
+              else if (operation == svn_diff_op_modified)
+                {
+                  SVN_ERR(print_git_diff_header_modified(
+                                                os, 
+                                                diff_cmd_baton->header_encoding,
+                                                path, subpool));
+                  label1 = diff_label(apr_psprintf(subpool, "a/%s", path1), rev1,
+                                      subpool);
+                  label2 = diff_label(apr_psprintf(subpool, "b/%s", path2), rev2,
+                                      subpool);
+                }
 
+              /* ### Print git headers for copies and renames too. */
             }
-          else if (operation == svn_diff_op_added)
-            {
-              SVN_ERR(print_git_diff_header_added(
-                                            os, 
-                                            diff_cmd_baton->header_encoding,
-                                            path, subpool));
-              label1 = diff_label("/dev/null", rev1, subpool);
-              label2 = diff_label(apr_psprintf(subpool, "b/%s", path2), rev2,
-                                  subpool);
-            }
-          else if (operation == svn_diff_op_modified)
-            {
-              SVN_ERR(print_git_diff_header_modified(
-                                            os, 
-                                            diff_cmd_baton->header_encoding,
-                                            path, subpool));
-              label1 = diff_label(apr_psprintf(subpool, "a/%s", path1), rev1,
-                                  subpool);
-              label2 = diff_label(apr_psprintf(subpool, "b/%s", path2), rev2,
-                                  subpool);
-            }
-
-          /* ### Print git headers for copies and renames too. */
-#endif
           /* Output the actual diff */
           SVN_ERR(svn_diff_file_output_unified3
                   (os, diff, tmpfile1, tmpfile2, label1, label2,

Modified: subversion/trunk/subversion/libsvn_diff/diff_file.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_diff/diff_file.c?rev=958537&r1=958536&r2=958537&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_diff/diff_file.c (original)
+++ subversion/trunk/subversion/libsvn_diff/diff_file.c Mon Jun 28 10:57:50 2010
@@ -543,6 +543,7 @@ static const apr_getopt_option_t diff_op
   { "ignore-all-space", 'w', 0, NULL },
   { "ignore-eol-style", SVN_DIFF__OPT_IGNORE_EOL_STYLE, 0, NULL },
   { "show-c-function", 'p', 0, NULL },
+  { "git-diff", 'g', 0, NULL },
   /* ### For compatibility; we don't support the argument to -u, because
    * ### we don't have optional argument support. */
   { "unified", 'u', 0, NULL },
@@ -598,6 +599,8 @@ svn_diff_file_options_parse(svn_diff_fil
         case 'p':
           options->show_c_function = TRUE;
           break;
+        case 'g':
+          options->use_git_format = TRUE;
         default:
           break;
         }

Modified: subversion/trunk/subversion/svn/main.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svn/main.c?rev=958537&r1=958536&r2=958537&view=diff
==============================================================================
--- subversion/trunk/subversion/svn/main.c (original)
+++ subversion/trunk/subversion/svn/main.c Mon Jun 28 10:57:50 2010
@@ -196,7 +196,11 @@ const apr_getopt_option_t svn_cl__option
                        "                            "
                        "    -p (--show-c-function):\n"
                        "                            "
-                       "       Show C function name in diff output.")},
+                       "       Show C function name in diff output.\n"
+                       "                            "
+                       "    -g (--git-diff):\n"
+                       "                            "
+                       "       Use git's extended diff format.")},
   {"targets",       opt_targets, 1,
                     N_("pass contents of file ARG as additional args")},
   {"depth",         opt_depth, 1,

Modified: subversion/trunk/subversion/tests/cmdline/getopt_tests_data/svn_help_log_switch_stdout
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/getopt_tests_data/svn_help_log_switch_stdout?rev=958537&r1=958536&r2=958537&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/getopt_tests_data/svn_help_log_switch_stdout (original)
+++ subversion/trunk/subversion/tests/cmdline/getopt_tests_data/svn_help_log_switch_stdout Mon Jun 28 10:57:50 2010
@@ -74,6 +74,8 @@ Valid options:
                                    Ignore changes in EOL style.
                                 -p (--show-c-function):
                                    Show C function name in diff output.
+                                -g (--git-diff):
+                                   Use git's extended diff format.
 
 Global options:
   --username ARG           : specify a username ARG