You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by Michael Maxwell <mm...@casl.umd.edu> on 2008/07/08 15:08:33 UTC

Parameters to 'diff'

A couple days ago, in a thread entitled "diff parameters in config file", I asked about using the ~/.subversion/config file to change some things about the way 'svn diff' works.  (Specifically, I wanted to change the '-' and '+' tags to the standard '<' and '>'.  I forgot to mention that I wanted to turn OFF the '-u' default parameter, which doesn't appear to be possible unless you use a different 'diff'.)

I received a single suggestion (thanks, David Weintraub!), who suggested using a shell script.  Apparently that's the only way to send extra parameters to the 'diff' command by default (as opposed to doing it on the command line each time you invoke it--that, or an alias in your .bashrc).  I guess I'm surprised at how primitive svn is in this respect; rcsdiff, for example, allows *all* diff parameters to be used (in addition to some rcs-specific ones):
       ...all options of diff(1) that apply to regular files are accepted,  
       with  the same meaning as for diff. [from the rcsdiff man page]

I have a suggestion: make it possible to add *any* diff-specific parameters by default in the config file.  It appears to me that the easiest way to do this would be to change the 'diff-cmd' variable there to be a "command", rather than an absolute path.  This would make it parallel to the 'editor-cmd' variable in that same config file.  (Alternatively, a separate variable for diff-parameters could be added, but then 'diff-cmd' and 'editor-cmd' would remain non-parallel, which is just plain confusing.)

It would be good to do the same for the diff3-cmd variable in the config file.

BTW, issue 668 in the 'bug' database originally called for this:
     The ~/.subversion/options conf file will control lots of
     things, among them:
        -- which editor to use (as in, $EDITOR), or none
        -- which options to pass to "diff" in "svn diff"
Note that the last line says *options*, not which 'diff'.  This issue got signed off without a discussion of the need to pass options, afaict.

This issue was addressed at
    http://svn.haxx.se/dev/archive-2007-03/1210.shtml
which, afaict, is not actually the SVN bug base.  This msg is mentioned in passing in Issue 2044, although issue 2044 does not seem to directly address the config file issue.  Issue 1390 also mentions a patch to allow "default diff -x options to be specified in the config file."  It is allegedly a duplicate (subset) of 2044, although again it's not clear to me that 2044 really does address the config file issue.  (2044 says "enable it [the fix, I guess] in response to a new config file option", but I'm not sure what that means.)

I'm new to this, so I don't know if I should add a note to the 2044 Issue.  The gist of such a note would be that resolution of 2044 needs to address the config file problem, as I have outlined above.  Is that appropriate?

   Mike Maxwell
   CASL/ U Md  

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org


Re: Parameters to 'diff'

Posted by Paul Koning <Pa...@dell.com>.
>>>>> "John" == John Peacock <jo...@havurah-software.org> writes:

 John> Michael Maxwell wrote:
 >> A couple days ago, in a thread entitled "diff parameters in config
 >> file", I asked about using the ~/.subversion/config file to change
 >> some things about the way 'svn diff' works.  (Specifically, I
 >> wanted to change the '-' and '+' tags to the standard '<' and '>'.
 >> I forgot to mention that I wanted to turn OFF the '-u' default
 >> parameter, which doesn't appear to be possible unless you use a
 >> different 'diff'.)

 John> Both context and unified diff formats are more reliable to
 John> apply programmatically and AFAICT most people think easier to
 John> read as well.  The commandline option --diff-cmd (points to the
 John> actual diff executable) and the --extensions/-x option (passed
 John> as extended arguments to the above) are there to provide a way
 John> to customize that behavior.

Yes, but svn supplies its own switches in addition to what -x calls
for, and depending on the diff you're invoking that may cause
trouble.  For example, --diff-cmd=xxdiff doesn't work because one of
the switches svn insists on passing is one xxdiff doesn't know about.

There should be a way to say "pass these switches AND NO OTHERS".  

      paul


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: Parameters to 'diff'

Posted by David Weintraub <qa...@gmail.com>.
My personal complaint with "svn diff" is if I specify my own "diff"
program, Subversion doesn't merely pass me the file names, it passes
also passes the "-u" parameter as well. That's frustrating. I would
prefer if I specify my own "diff" that Subversion would just pass me
the file names.

It is nice that you can use a third party diff command instead of the
built in diff (something that couldn't be done in CVS's diff command).
Although I mainly use Subversion directly from the command line, my
preferred diff command is vimdiff.

--
David Weintraub
qazwart@gmail.com


On Tue, Jul 8, 2008 at 11:29 AM, John Peacock
<jo...@havurah-software.org> wrote:
> Michael Maxwell wrote:
>>
>> A couple days ago, in a thread entitled "diff parameters in config
>> file", I asked about using the ~/.subversion/config file to change
>> some things about the way 'svn diff' works.  (Specifically, I wanted
>> to change the '-' and '+' tags to the standard '<' and '>'.  I forgot
>> to mention that I wanted to turn OFF the '-u' default parameter,
>> which doesn't appear to be possible unless you use a different
>> 'diff'.)
>
> Both context and unified diff formats are more reliable to apply
> programmatically and AFAICT most people think easier to read as well. The
> commandline option --diff-cmd (points to the actual diff executable) and the
> --extensions/-x option (passed as extended arguments to the above) are there
> to provide a way to customize that behavior.
>
> I don't believe the builtin Subversion diff code produces anything except
> unified diffs, so you are going to have to use an external application in
> any case.  So having to write a wrapper script is inevitable in your
> situation.
>
> Sorry
>
> John
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
> For additional commands, e-mail: users-help@subversion.tigris.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

RE: Parameters to 'diff'

Posted by Michael Maxwell <mm...@casl.umd.edu>.
John Peacock wrote:
> The issue is that the commandline option --diff-cmd is 
> documented as being only the executable, so the config file 
> option is only the executable (since it shares the same code 
> path).  

Well, you're right that you can specify a command-line parameter for the editor in the '--editor-cmd' parameter, but you can't specify a command-line parameter for diff in the '--diff-cmd' parameter.  This is parallel to the way the config file works.  However, this is IMO *not* clearly documented for the command line (although it is clearly documented in the config file).  For 'commit' (from 'svn help commit'):
   --editor-cmd arg         : use ARG as external editor
And for 'diff':
   --diff-cmd arg           : use ARG as diff command
If anything, I would have guessed from these descriptions that the behavior was the opposite, that is I would have guessed that '--editor-cmd' would not allow passing of parameters, while '--diff-cmd' would.  But I suppose that's just a minor documentation issue.

If it's considered important to retain the present working of command-line parameters and config files, so as not to break existing installations, I respect that (even though I'd much prefer that it be changed, because the non-parallelism between the editor and the 'diff' command is IMO confusing and inelegant).  In which case I would say, add another variable in the config file, call it 'diff-parameters', which would be parallel to the -x command line parameter.

Also, I strongly agree with Paul Koning's email:
> but svn supplies its own switches in addition to what -x calls for, 
> and depending on the diff you're invoking that may cause trouble
It's actually even worse than that: '-u' is not only allowed after the '-x' parameter, it's also the default.  Which means that it's not only useless as a parameter, there's no way to turn it off!  

So, as Paul says:
> There should be a way to say "pass these switches AND NO OTHERS".  
and there should be a way to pass no switches at all, i.e.
   -x ''
should *not* pass the -u parameter.

   Mike Maxwell
   CASL/ U MD

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org


Re: Parameters to 'diff'

Posted by John Peacock <jo...@havurah-software.org>.
Michael Maxwell wrote:
> Well, it wouldn't be inevitable if the dadburned config file treated
> 'diff-cmd' the same way it already treats 'editor-cmd', namely that
> you can supply parameters right there.  (There are a host of other
> parameters to e.g. the gnu 'diff' that one might also want to pass
> on.)

The issue is that the commandline option --diff-cmd is documented as 
being only the executable, so the config file option is only the 
executable (since it shares the same code path).  I suspect it would be 
easiest to add a new diff-extensions line to the config file (to match 
the command line --extensions).

Patches welcome?  Compare and contrast how editor works (see svn/util.c) 
and diff_cmd (see libsvn_client/diff.c).

Read the Hacking guidelines before submitting anything, to save your skin...

John

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

RE: Parameters to 'diff'

Posted by Michael Maxwell <mm...@casl.umd.edu>.
John Peacock wrote:
> Both context and unified diff formats are more reliable to 
> apply programmatically and AFAICT most people think easier to 
> read as well. 

Well, I'm an Old Fogie.  Twenty plus years of looking at '<' and '>', and not having the context unless I ask for it...  I suppose there might be some other old fogies out there, if we haven't all died off.

> The commandline option --diff-cmd (points to the actual diff 
> executable) and the --extensions/-x option (passed as 
> extended arguments to the
> above) are there to provide a way to customize that behavior.

Right, and us Old Fogies appreciate you Young 'Uns doing that for us.  My point is that these options should be provided for in the config file, *as well as* on the command line.  (We don't like typing it every time.  Arthritis, I 'spect.)

> I don't believe the builtin Subversion diff code produces 
> anything except unified diffs, so you are going to have to 
> use an external application in any case.  So having to write 
> a wrapper script is inevitable in your situation.

Well, it wouldn't be inevitable if the dadburned config file treated 'diff-cmd' the same way it already treats 'editor-cmd', namely that you can supply parameters right there.  (There are a host of other parameters to e.g. the gnu 'diff' that one might also want to pass on.)

> Sorry

Not half as sorry as you'll be when you get to my age.

   Mike Maxwell
   CASL/ U Md  

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org


Re: Parameters to 'diff'

Posted by John Peacock <jo...@havurah-software.org>.
Michael Maxwell wrote:
> A couple days ago, in a thread entitled "diff parameters in config
> file", I asked about using the ~/.subversion/config file to change
> some things about the way 'svn diff' works.  (Specifically, I wanted
> to change the '-' and '+' tags to the standard '<' and '>'.  I forgot
> to mention that I wanted to turn OFF the '-u' default parameter,
> which doesn't appear to be possible unless you use a different
> 'diff'.)

Both context and unified diff formats are more reliable to apply 
programmatically and AFAICT most people think easier to read as well. 
The commandline option --diff-cmd (points to the actual diff executable) 
and the --extensions/-x option (passed as extended arguments to the 
above) are there to provide a way to customize that behavior.

I don't believe the builtin Subversion diff code produces anything 
except unified diffs, so you are going to have to use an external 
application in any case.  So having to write a wrapper script is 
inevitable in your situation.

Sorry

John

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org