Question

I often use this command line that works great on Subversion 1.6.11 and GNU diff 2.8.1.

svn diff -x '--unified --ignore-space-change --ignore-all-space --ignore-eol-style --show-c-function' --no-diff-deleted my-file | vim -

However I want to increase the context lines using the diff option --unified=40 but all my attempts fail:

$ svn diff -x '--unified=40' my-file
svn: Error parsing diff options: Missing parameter for the specified command line option

$ svn diff -x '--unified 40' my-file
svn: Invalid argument '40' in diff options

$ svn diff -x '--unified\=40' my-file
svn: Error parsing diff options: Bad character specified on command line

$ svn diff -x '-u 40' my-file
svn: Invalid argument '40' in diff options

$ svn diff -x '-u=40' my-file
svn: Error parsing diff options: Bad character specified on command line

$ svn diff -x '-U' my-file
svn: Error parsing diff options: Bad character specified on command line

I also want to ignore changes in comment lines using the diff option --ignore-matching-lines='^[ \t]*#' but same errors.

Is there a workaround to this svn diff -x issue?

Was it helpful?

Solution

Subversion doesn't use GNU diff to generate the diff. It has it's own implementation of diff (see the last paragraph of the section at the link). The internal diff implementation only has a few options as you can see from the output of svn help diff:

-x [--extensions] ARG    : Specify differencing options for external diff or
                          internal diff or blame. Default: '-u'. Options are
                          separated by spaces. Internal diff and blame take:
                            -u, --unified: Show 3 lines of unified context
                            -b, --ignore-space-change: Ignore changes in
                              amount of white space
                            -w, --ignore-all-space: Ignore all white space
                            --ignore-eol-style: Ignore changes in EOL style
                            -p, --show-c-function: Show C function name

You probably want to do svn diff --diff-cmd=/usr/bin/diff -x '--unified=40' my-file so that Subversion will choose the external diff too at /usr/bin/diff (or whatever path you want).

You can also configure Subversion to always use the external diff command through the configuration file. There is a section on using external diff and merge tools in the Subversion book.

OTHER TIPS

You can write a small shell script that does this:

#!/bin/bash
diff --unified=40 <(svn cat "$1") "$1"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top