linux统一diff格式补丁文件块范围双@@后紧跟的字串含义与说明

补丁文件块范围信息后紧跟(加红部分):例如:

@@ -l,s +l,s @@ optional section heading

一、@@ -l,s +l,s @@:

这一部分表示的就是块的范围,其中-号表示源文件,+号表示新文件,l表示开始的行,s表示对于新旧文件各自有s行改动的块(s is the number of lines the change hunk applies to for each respective file.维基百科翻译过来的,原文):

事实上,s除了包括修改的块行(the change hunk),还包括上下文行数:

 

  • 对于旧文件来说,s表示上下文行+删除(修改)的行;
  • 对于新文件来说,s表示上下文行+增加(修改)的行。
  • 如果块大小信息与块行数不同,那么diff操作将被视为非法并拒绝diff操作。
  • 另外,在大多数GNU diff中,s不一定是必须要有的,可以去掉s以及前面的逗号,这种情况下,s值默认为1,即表示l开始,持续1行。

=================@@ -l,s +l,s @@ =原文========================

The hunk range for the original should be the sum of all contextual and deletion (including changed) hunk lines. The hunk range for the new file should be a sum of all contextual and addition (including changed) hunk lines. If hunk size information does not correspond with the number of lines in the hunk, then the diff could be considered invalid and be rejected.

===========================================================


二、optional section heading:

这一部分是可选的章节头部,表示该章节的标题或者该部分块的功能,主要的作用是为了方便可读性,当用GNU diff执行diff操作时,这个头部由正则表达式匹配指定(也就是头部的内容由正则表达式来指定)。如果你想知道正则表达式如何匹配的,可参考该说明

================optional section heading=原文====================

Optionally, the hunk range can be followed by the heading of the section or function that the hunk is part of. This is mainly useful to make the diff easier to read. When creating a diff with GNU diff, the heading is identified by regular expression matching

===========================================================

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值