Subversion svn has its own built in diff but its capabilities are not as wide as GNU diff. But there is a work around for everything.
For example, if you want to GNU diff and show only file names not details, diff -q would do. Same thing in svn diff would be like this:
lets break it down:
svn diff is the command (duh)
--diff-cmd means we want to use an external program to display the differences, which in our case is
"diff"
-x this external program is going to get some options (--extensions= -x) which in your case is
"-q"
The rest is self explanatory i guess but let me continue.
For every file that differs, the output of the svn diff --diff-cmd "diff" -x "-q" . will be
File <filename> <revison> and <filename> <revison2> differ
Index: <filename>
that is why we grep Index
and then we cut (cut) this string using space (" ") as delimeter (-d) and just choose the second field (-f 2), so we dont get the Index: part
and Ta-Taaaa!
svn diff --diff-cmd "diff" -x "-q" . | grep Index | cut -d " " -f 2
Now following the same idea, we will write how to svn diff side-by-side
svn diff --diff-cmd "diff" -x "-y"
And if you are only interested in the lines that differ
svn diff --diff-cmd "diff" -x "-y --supress-common-lines
Now you know how to extend this to any diff option.. go play child.
For example, if you want to GNU diff and show only file names not details, diff -q would do. Same thing in svn diff would be like this:
svn diff --diff-cmd "diff" -x "-q" . | grep Index | cut -d " " -f 2
lets break it down:
svn diff is the command (duh)
--diff-cmd means we want to use an external program to display the differences, which in our case is
"diff"
-x this external program is going to get some options (--extensions= -x) which in your case is
"-q"
The rest is self explanatory i guess but let me continue.
For every file that differs, the output of the svn diff --diff-cmd "diff" -x "-q" . will be
File <filename> <revison> and <filename> <revison2> differ
Index: <filename>
that is why we grep Index
and then we cut (cut) this string using space (" ") as delimeter (-d) and just choose the second field (-f 2), so we dont get the Index: part
and Ta-Taaaa!
svn diff --diff-cmd "diff" -x "-q" . | grep Index | cut -d " " -f 2
Now following the same idea, we will write how to svn diff side-by-side
svn diff --diff-cmd "diff" -x "-y"
And if you are only interested in the lines that differ
svn diff --diff-cmd "diff" -x "-y --supress-common-lines
" Now you know how to extend this to any diff option.. go play child.
No comments:
Post a Comment