Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

svn diff how to only show changed line

Tags:

svn

When I used "svn diff en.lua ", I get this result:

 num="Amount",
 all="All",
 class="Quality",
-own="Have",
+own="Have2",
 paper="Specs",
 piece="Shard",
 not_enough=" not enough",

but I only want to see this

-own="Have",
+own="Have2",

I'm wondering which parameter should I use for "svn diff"?

like image 488
taotao Avatar asked Feb 08 '23 01:02

taotao


2 Answers

At least with svn 1.9, you can use svn diff -x -U0. I'm unsure whether the option is available in earlier versions. This does not seem to be documented in the svn book, however the command line documentation shows:

$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
                               -U ARG, --context ARG: Show ARG lines of context
                               -p, --show-c-function: Show C function name
like image 75
RjOllos Avatar answered Mar 17 '23 23:03

RjOllos


This will work for any SVN version:

svn diff some_file.extension | sed -n -e '/@@/,$p' | grep -vE "^( |@@)"

Explanation:

  • The sed command skips header.
  • The grep command skips non-matched lines (which are prefixed with space) and changes info.

So you should only be left with lines starting with a single + or -.

like image 23
Nux Avatar answered Mar 17 '23 22:03

Nux