G0574's Archiver

弯月圆刀 发表于 2008-10-5 11:00

diff

从来没有静下心来仔细的看过diff。今天在维基百科上面看到了,记录一下。

[url]http://en.wikipedia.org/wiki/Diff[/url]

命令行:diff original new
程序的输出记录了“一系列的变化过程”,通过这个变化过程,原来的文件(original)就变成了新的文件(new)。这个记录一系列变化过程的文件就是diff文件或者说是patch。

所以可以这么推理,只要知道三个文件中的任何两个文件。original,new,patch。就可以计算出另一个文件。

格式之一Unified format:[code]--- original timestamp
+++ new      timestamp
@@ -1,3 +1,9 @@
+This is an important
+notice! It should
+therefore be located at
+the beginning of this
+document!
+
This part of the
document has stayed the
same from version to
@@ -5,16 +11,10 @@
be shown if it doesn't
change.  Otherwise, that
would not be helping to
-compress the size of the
-changes.
-
-This paragraph contains
-text that is outdated.
-It will be deleted in the
-near future.
+compress anything.

It is important to spell
-check this dokument. On
+check this document. On
the other hand, a
misspelled word isn't
the end of the world.
@@ -22,3 +22,7 @@
this paragraph needs to
be changed.  Things can
be added after it.
+
+This paragraph contains
+important new additions
+to this document.
[/code]---表示源文件
+++表示新文件
@@ @@之间记录变化段落,

正规的unified格式:the traditional unified diff format, which shows two files A and B with a single column that has - (minus — appears in A but removed in B), + (plus — missing in A but added to B), or " " (space — unchanged) prefix,

git diff 格式:this format compares two or more files file1, file2,… with one file X, and shows how X differs from each of fileN. One column for each of fileN is prepended to the output line to note how X's line is different from it.

[[i] 本帖最后由 弯月圆刀 于 2008-10-6 09:47 编辑 [/i]]

页: [1]

Powered by Discuz! Archiver 6.1.0  © 2001-2007 Comsenz Inc.