如何让diff看起来像svn diff?

dif*_*ewb 18 svn diff

我很愚蠢,没有google fu.你如何得到差异(在os x上,如果它重要......)看起来像svn差异?也无法从手册页中找到它.:(

我想要的是

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.
Run Code Online (Sandbox Code Playgroud)

Car*_*rum 27

你想要-u标志.

diff -u file1 file2
Run Code Online (Sandbox Code Playgroud)

diff手册页:

   -u  -U NUM  --unified[=NUM]
          Output NUM (default 3) lines of unified context.
Run Code Online (Sandbox Code Playgroud)

它不完全相同(例如,没有大排等号),但它应该做你想要的.你上面的例子:

--- 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.
Run Code Online (Sandbox Code Playgroud)


blu*_*her 5

subversion使用统一diff格式的略微扩展版本.Diff上的维基百科页面解释了格式本身,并且还注意到与颠覆格式的差异.

如前所述,diff工具(详见其手册页)使用该-u选项生成统一差异.