是否可以添加评论到一个差异文件(统一)? [英] is it possible to add a comment to a diff file (unified)?

查看:90
本文介绍了是否可以添加评论到一个差异文件(统一)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有可能将一些未解析的内容添加到作为注释忽略的差异文件(统一)。



一个很好的用法会有git diffs增加了重要的信息,比如从哪个分支出来的diff(特别是当使用--full-index选项,它仅仅显示blob引用)。



  --- from   -file文件修改时间
+++文件修改时间

这个标题之前的任何内容都被忽略,所以你可以在这里添加任何注释,例如:

 这可能是这个补丁的一些有用的描述:
将被diff / patch工具忽略。
--- a / foo 2002-02-21 23:30:39.942229878 -0800
+++ b / foo 2002-02-21 23:30:50.442260588 -0800
@@ -1,7 +1,6 @@
- 可以说的方式不是永恒的方式;
- 可以命名的名称不是永恒的名字。
无名者是天地的起源;
- 命名是万物之母。
+命名是万物之母。
+
因此,让我们总是存在不存在的
,这样我们就可以看到它们的微妙之处
并让它始终存在

Git本身在标题前为某些元数据使用此空格,例如:

  diff --git a / foo b / foo 
index 59a4d1f..e48dfe7 100644
--- a / foo
+++ b / foo


I wonder if it's possible to add a certain amount of unparsed content to a diff file (unified) that is ignored as a comment.

One good use of this would be having git diffs augmented with important information such as from which branch is that diff from (especially when using the --full-index option, which merely displays the blob references).

解决方案

The unified diff starts with two line header:

 --- from-file from-file-modification-time
 +++ to-file to-file-modification-time

Anything before this header is ignored, so you can add any comment here, for example:

 This may be some useful description of this patch that
 will be ignored by the diff/patch utility.
 --- a/foo  2002-02-21 23:30:39.942229878 -0800
 +++ b/foo  2002-02-21 23:30:50.442260588 -0800
 @@ -1,7 +1,6 @@
 -The Way that can be told of is not the eternal Way;
 -The name that can be named is not the eternal name.
  The Nameless is the origin of Heaven and Earth;
 -The Named is the mother of all things.
 +The named is the mother of all things.
 +
  Therefore let there always be non-being,
    so we may see their subtlety,
  And let there always be being,

Git itself uses this space before header for some metadata, for example:

diff --git a/foo b/foo
index 59a4d1f..e48dfe7 100644
--- a/foo
+++ b/foo

这篇关于是否可以添加评论到一个差异文件(统一)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆