On Sunday, November 06, 2011 10:27:01 am Daniel Shahaf wrote:
> Perhaps the solution is to make 'svn diff' use --diff-cmd for propdiffs
> too?  It seems that currently --diff-cmd is only used for file content
> diffs.

I guess this is sort of a feature. As Julian pointed out, the property diffs 
are output using a different hunk format that starts with ## instead of @@. 
Thus invoking an external diff utility (which does not know whether it is 
diffing, content or property) would actually make the problem worse.

FWIW, I implemented the --patch option for 'svn diff' as suggested - implying 
no property diffs and copies-as-additions. Patch against trunk, r1202879; 
survives 'make check'.

[[[
* subversion/svn/cl.h
* subversion/svn/main.c
  New option, --patch for svn diff.

* subversion/include/svn_client.h
  (svn_client_diff6,svn_client_diff_peg6): New argument, ignore_prop_diff.
  (svn_client_diff5,svn_client_diff_peg5): Update comments.

* subversion/libsvn_client/deprecated.c
  (svn_client_diff5,svn_client_diff_peg5): Pass FALSE as ignore_prop_diff.

* subversion/libsvn_client/diff.c
  (diff_cmd_baton): New field, ignore_prop_diff
  (diff_props_changed): Do nothing if diff_cmd_baton->ignore_prop_diff is set.
  (svn_client_diff6,svn_client_diff_peg6): Pass ignore_prop_diff downstream
  via diff_cmd_baton.

* subversion/svn/diff-cmd.c
  (svn_cl__diff): Handle --patch: ignore property diff, force
  --show-copies-as-adds.

* subversion/svn/log-cmd.c
  (log_entry_receiver): Request property changes from svn_client_diff6.
]]]

Best regards,
Alexey.

> 
> C. Michael Pilato wrote on Thu, Nov 03, 2011 at 15:16:23 -0400:
> > The introduction of the --git option to 'svn diff' opens the door for
> > different "flavors" for 'svn diff' output.  Would you be interested in a
> > new 'svn diff --patch' flavor, which generates only diff output that's
> > suitable for consumption with GNU patch?  Implied by --patch would be no
> > property diff output and the display of copied items as additions (like
> > --show-copies-as-adds does).
> > 
> > Of course, --no-property-diff works for me, too.  :-)
> > 
> > On 11/03/2011 03:05 PM, Alexey Neyman wrote:
> > > Hi all,
> > > 
> > > Sorry for a long delay :) 5 years ago, I sent a patch to the mailing
> > > list that
> > > 
> > > would allow to specify what to include/exclude from the diff output:
> > >   http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessag
> > >   eId=742594
> > > 
> > > There were two problems this patch tried to address:
> > > 
> > > 1. There was no way to exclude properties from the diff output.
> > > 
> > > 2. There was no way to obtain a list of modified/added/deleted files
> > > and whether the content and/or properties have been modified.
> > > 
> > > I got a response from Ben Collins-Sussman that the patch I sent is
> > > superseded by --summarize option which was implemented in the trunk
> > > (which would
> > > 
> > > eventually become 1.4):
> > >   http://svn.haxx.se/dev/archive-2006-06/0202.shtml
> > > 
> > > Actually, --summarize only addresses the issue #2, but not the issue
> > > #1. As to issue #1, ability to disable property diffs is still missing
> > > from Subversion.
> > > 
> > > Common wisdom suggests running the diff through 'filterdiff --clean':
> > >   http://stackoverflow.com/questions/2755848/how-do-you-get-subversion-
> > >   diff-
> > > 
> > > summary-to-ignore-mergeinfo-properties
> > > 
> > >   http://stackoverflow.com/questions/402522/is-there-a-metadata-exclusi
> > >   on-
> > > 
> > > filter-for-the-svn-diff-command
> > > 
> > > But this is still unreliable: if property text includes a diff-like
> > > chunk, it will go through.
> > > 
> > > What is the sentiment about implementing --no-property-diff option to
> > > 'svn diff'? I can implement it if there's agreement such option is
> > > needed.
> > > 
> > > Regards,
> > > Alexey.
Index: subversion/svn/cl.h
===================================================================
--- subversion/svn/cl.h	(revision 1202879)
+++ subversion/svn/cl.h	(working copy)
@@ -229,6 +229,7 @@
   svn_boolean_t show_diff;        /* produce diff output (maps to --diff) */
   svn_boolean_t internal_diff;    /* override diff_cmd in config file */
   svn_boolean_t use_git_diff_format; /* Use git's extended diff format */
+  svn_boolean_t use_patch_diff_format; /* Output compatible with GNU patch */
   svn_boolean_t allow_mixed_rev; /* Allow operation on mixed-revision WC */
   svn_boolean_t include_externals; /* Recurses (in)to file & dir externals */
 } svn_cl__opt_state_t;
Index: subversion/svn/diff-cmd.c
===================================================================
--- subversion/svn/diff-cmd.c	(revision 1202879)
+++ subversion/svn/diff-cmd.c	(working copy)
@@ -171,6 +171,9 @@
   const char *old_target, *new_target;
   apr_pool_t *iterpool;
   svn_boolean_t pegged_diff = FALSE;
+  svn_boolean_t show_copies_as_adds =
+    opt_state->use_patch_diff_format ? TRUE : opt_state->show_copies_as_adds;
+  svn_boolean_t ignore_prop_diff = opt_state->use_patch_diff_format;
   int i;
   const svn_client_diff_summarize_func_t summarize_func =
     (opt_state->xml ? summarize_xml : summarize_regular);
@@ -361,8 +364,9 @@
                      opt_state->depth,
                      ! opt_state->notice_ancestry,
                      opt_state->no_diff_deleted,
-                     opt_state->show_copies_as_adds,
+                     show_copies_as_adds,
                      opt_state->force,
+                     ignore_prop_diff,
                      opt_state->use_git_diff_format,
                      svn_cmdline_output_encoding(pool),
                      outstream,
@@ -406,8 +410,9 @@
                      opt_state->depth,
                      ! opt_state->notice_ancestry,
                      opt_state->no_diff_deleted,
-                     opt_state->show_copies_as_adds,
+                     show_copies_as_adds,
                      opt_state->force,
+                     ignore_prop_diff,
                      opt_state->use_git_diff_format,
                      svn_cmdline_output_encoding(pool),
                      outstream,
Index: subversion/svn/log-cmd.c
===================================================================
--- subversion/svn/log-cmd.c	(revision 1202879)
+++ subversion/svn/log-cmd.c	(working copy)
@@ -309,6 +309,7 @@
                                TRUE, /* no diff deleted */
                                FALSE, /* show copies as adds */
                                FALSE, /* ignore content type */
+                               FALSE, /* ignore prop diff */
                                FALSE, /* use git diff format */
                                svn_cmdline_output_encoding(pool),
                                outstream,
Index: subversion/svn/main.c
===================================================================
--- subversion/svn/main.c	(revision 1202879)
+++ subversion/svn/main.c	(working copy)
@@ -124,6 +124,7 @@
   opt_diff,
   opt_internal_diff,
   opt_use_git_diff_format,
+  opt_use_patch_diff_format,
   opt_allow_mixed_revisions,
   opt_include_externals,
 } svn_cl__longopt_t;
@@ -341,6 +342,12 @@
                        N_("override diff-cmd specified in config file")},
   {"git", opt_use_git_diff_format, 0,
                        N_("use git's extended diff format")},
+  {"patch", opt_use_patch_diff_format, 0,
+                       N_("generate diff suitable for GNU patch;\n"
+                       "                             "
+                       "implies show-copies-as-adds and ignores property\n"
+                       "                             "
+                       "differences")},
   {"allow-mixed-revisions", opt_allow_mixed_revisions, 0,
                        N_("Allow merge into mixed-revision working copy.\n"
                        "                             "
@@ -538,7 +545,7 @@
     {'r', 'c', opt_old_cmd, opt_new_cmd, 'N', opt_depth, opt_diff_cmd,
      opt_internal_diff, 'x', opt_no_diff_deleted, opt_show_copies_as_adds,
      opt_notice_ancestry, opt_summarize, opt_changelist, opt_force, opt_xml,
-     opt_use_git_diff_format} },
+     opt_use_git_diff_format, opt_use_patch_diff_format} },
   { "export", svn_cl__export, {0}, N_
     ("Create an unversioned copy of a tree.\n"
      "usage: 1. export [-r REV] URL[@PEGREV] [PATH]\n"
@@ -2046,6 +2053,9 @@
       case opt_internal_diff:
         opt_state.internal_diff = TRUE;
         break;
+      case opt_use_patch_diff_format:
+        opt_state.use_patch_diff_format = TRUE;
+        break;
       case opt_use_git_diff_format:
         opt_state.use_git_diff_format = TRUE;
         break;
Index: subversion/include/svn_client.h
===================================================================
--- subversion/include/svn_client.h	(revision 1202879)
+++ subversion/include/svn_client.h	(working copy)
@@ -2877,6 +2877,7 @@
                  svn_boolean_t no_diff_deleted,
                  svn_boolean_t show_copies_as_adds,
                  svn_boolean_t ignore_content_type,
+                 svn_boolean_t ignore_prop_diff,
                  svn_boolean_t use_git_diff_format,
                  const char *header_encoding,
                  svn_stream_t *outstream,
@@ -2886,7 +2887,8 @@
                  apr_pool_t *pool);
 
 /** Similar to svn_client_diff6(), but with @a outfile and @a errfile,
- * instead of @a outstream and @a errstream.
+ * instead of @a outstream and @a errstream, and always showing property
+ * changes.
  *
  * @deprecated Provided for backward compatibility with the 1.7 API.
  * @since New in 1.7.
@@ -3035,6 +3037,7 @@
                      svn_boolean_t no_diff_deleted,
                      svn_boolean_t show_copies_as_adds,
                      svn_boolean_t ignore_content_type,
+                     svn_boolean_t ignore_prop_diff,
                      svn_boolean_t use_git_diff_format,
                      const char *header_encoding,
                      svn_stream_t *outstream,
@@ -3044,7 +3047,8 @@
                      apr_pool_t *pool);
 
 /** Similar to svn_client_diff_peg6(), but with @a outfile and @a errfile,
- * instead of @a outstream and @a errstream.
+ * instead of @a outstream and @a errstream, and always showing property
+ * changes.
  *
  * @deprecated Provided for backward compatibility with the 1.7 API.
  * @since New in 1.7.
Index: subversion/libsvn_client/deprecated.c
===================================================================
--- subversion/libsvn_client/deprecated.c	(revision 1202879)
+++ subversion/libsvn_client/deprecated.c	(working copy)
@@ -864,7 +864,7 @@
   return svn_client_diff6(diff_options, path1, revision1, path2,
                           revision2, relative_to_dir, depth,
                           ignore_ancestry, no_diff_deleted,
-                          show_copies_as_adds, ignore_content_type,
+                          show_copies_as_adds, ignore_content_type, FALSE,
                           use_git_diff_format, header_encoding,
                           outstream, errstream, changelists, ctx, pool);
 }
@@ -992,6 +992,7 @@
                               no_diff_deleted,
                               show_copies_as_adds,
                               ignore_content_type,
+                              FALSE,
                               use_git_diff_format,
                               header_encoding,
                               outstream,
Index: subversion/libsvn_client/diff.c
===================================================================
--- subversion/libsvn_client/diff.c	(revision 1202879)
+++ subversion/libsvn_client/diff.c	(working copy)
@@ -762,6 +762,9 @@
      relative to for output generation (see issue #2723). */
   const char *relative_to_dir;
 
+  /* Whether property differences are ignored. */
+  svn_boolean_t ignore_prop_diff;
+
   /* Whether we're producing a git-style diff. */
   svn_boolean_t use_git_diff_format;
 
@@ -802,6 +805,10 @@
   apr_array_header_t *props;
   svn_boolean_t show_diff_header;
 
+  /* If property differences are ignored, there's nothing to do. */
+  if (diff_cmd_baton->ignore_prop_diff)
+    return SVN_NO_ERROR;
+
   SVN_ERR(svn_categorize_props(propchanges, NULL, NULL, &props,
                                scratch_pool));
 
@@ -2398,6 +2405,7 @@
                  svn_boolean_t no_diff_deleted,
                  svn_boolean_t show_copies_as_adds,
                  svn_boolean_t ignore_content_type,
+                 svn_boolean_t ignore_prop_diff,
                  svn_boolean_t use_git_diff_format,
                  const char *header_encoding,
                  svn_stream_t *outstream,
@@ -2427,6 +2435,7 @@
 
   diff_cmd_baton.force_empty = FALSE;
   diff_cmd_baton.force_binary = ignore_content_type;
+  diff_cmd_baton.ignore_prop_diff = ignore_prop_diff;
   diff_cmd_baton.relative_to_dir = relative_to_dir;
   diff_cmd_baton.use_git_diff_format = use_git_diff_format;
   diff_cmd_baton.no_diff_deleted = no_diff_deleted;
@@ -2455,6 +2464,7 @@
                      svn_boolean_t no_diff_deleted,
                      svn_boolean_t show_copies_as_adds,
                      svn_boolean_t ignore_content_type,
+                     svn_boolean_t ignore_prop_diff,
                      svn_boolean_t use_git_diff_format,
                      const char *header_encoding,
                      svn_stream_t *outstream,
@@ -2480,6 +2490,7 @@
 
   diff_cmd_baton.force_empty = FALSE;
   diff_cmd_baton.force_binary = ignore_content_type;
+  diff_cmd_baton.ignore_prop_diff = ignore_prop_diff;
   diff_cmd_baton.relative_to_dir = relative_to_dir;
   diff_cmd_baton.use_git_diff_format = use_git_diff_format;
   diff_cmd_baton.no_diff_deleted = no_diff_deleted;

Reply via email to