Diff 这行是什么?@-9,9+;9,10@@在差异文件中是什么意思?
请有人解释一下下面示例Diff 这行是什么?@-9,9+;9,10@@在差异文件中是什么意思?,diff,Diff,请有人解释一下下面示例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)) …通过行号和正在编辑的块的大小(更改前后)指定源文件和目标文件
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))
…通过行号和正在编辑的块的大小(更改前后)指定源文件和目标文件中发生更改的位置
具体而言:
@@ -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.
也就是说:在原始文件中,正在修改的hunk由9行组成,从第9行开始;在目标文件中,从第9行开始有10行
请参阅GNU diffutils文档中的。谢谢,这太棒了。我非常感谢GNU文档的链接。目前我正在阅读一本介绍性的C语言书,在这一章中,作者引用了一个diff文件,几乎没有关于各种diff文件格式的上下文;我的谷歌搜索在
patch vs.diff
上找到了大量的页面,这是没有帮助的…因此我提出了一个基本的问题。。。但是这个图表非常清楚!
@@ -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.