2014-10-31 39 views
0

有人可以在下面的示例diff輸出(即以@@開頭的輸出)中解釋第三行嗎?我明白由剩餘的線表示的變化,但我有麻煩的是第三行的感覺......@@ -9,9 +9,10 @@在diff文件中的含義是什麼?

--- a/code/c-skeleton/Makefile 
+++ b/code/c-skeleton/Makefile 
@@ -9,9 +9,10 @@ 
TEST_SRC=$(wildcard tests/*_tests.c) 
TESTS=$(patsubst %.c,%,$(TEST_SRC)) 

回答

1
@@ -9,9 +9,10 @@ 

...指定將源文件和目標文件改變發生,通過行號以及正在編輯的塊的大小,在更改之前和之後。

具體來說:

@@ -9,9 +9,10 @@ 
^ ^^^^^^
| || | || \----- The "10" is the number of lines in the hunk after being 
| || | ||  modified; this patch, then, must add a line, since the 
| || | ||  new count (of 10) is longer than the old count (of 9). 
| || | |\------- This "9" is the line number in the new file where the 
| || | |   modified hunk is placed. 
| || | \-------- This "+" is a hint that the following numbers refer to 
| || |   the new file, after modification. 
| || \---------- This "9" is the number of lines in the hunk before being 
| ||    modified. 
| |\------------ This "9" is the line number in the original file. 
| \------------- This "-" is a hint that the following numbers refer to the 
|     original file. 
\---------------- This "@@" is a marker indicating that this is the start of a 
        new hunk. 

也就是說:在原始文件中,大塊被修改由起始於線9 9線;在目標文件中,它是從第9行開始的10行。

請參閱GNU diffutils文檔中的detailed description of unified diff format

+0

謝謝,這真棒。我很欣賞與GNU文檔的鏈接。目前我正在閱讀一本介紹性的C語言書籍,在本章中,作者引用了diff文件,其中包含各種diff文件格式的上下文;我的谷歌搜索在很大程度上反映了'patch vs. diff'的頁面,這對我來說是無益的...因此我的基本問題......但是這個圖表非常清楚! – iceman 2014-10-31 05:49:40

相關問題