Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

howto make diff look like svn diff?

Tags:

diff

svn

I'm bad dumb and having no google fu. How do you get diff (on os x if it matters...) to look like svn diffs? Couldn't figure it out from the man page either. :(

What I want

Index: test.txt
===================================================================
--- test.txt (revision 365)
+++ test.txt (working copy)
@@ -1,7 +1,9 @@
 This
 is
 the
-original
+updated
+and
+awesomer
 file.

-Unf.
+Duh.
like image 348
diffnewb Avatar asked Oct 16 '09 22:10

diffnewb


People also ask

How does svn compare files line by line?

Just hold down the Shift key while you right click on the file. Then select TortoiseSVN → Diff with URL. In the following dialog, specify the URL in the repository with which you want to compare your local file to.

How do I compare two revisions in svn?

Pick the two revisions you want to compare then use Context Menu → Compare Revisions. If you want to compare the same item in two different trees, for example the trunk and a branch, you can use the repository browser to open up both trees, select the file in both places, then use Context Menu → Compare Revisions.

What is the use of svn diff command?

The svn diff command reveals the differences between your working copy and the copy in the master SVN repository.


1 Answers

You want the -u flag.

diff -u file1 file2

From the diff man page:

   -u  -U NUM  --unified[=NUM]
          Output NUM (default 3) lines of unified context.

It's not exactly the same (no big row of equals signs, for example), but it should do what you want. Your example from above:

--- file1   2009-10-16 15:14:24.000000000 -0700
+++ file2   2009-10-16 15:14:50.000000000 -0700
@@ -1,7 +1,9 @@
 This
 is
 the
-original
+updated
+and
+awesomer
 file.

-Unf.
+Duh.
like image 130
Carl Norum Avatar answered Oct 02 '22 19:10

Carl Norum