什么是“@@ -1 +1 @”意味着在Git的差异输出? [英] What does "@@ -1 +1 @@" mean in Git's diff output?

查看:91
本文介绍了什么是“@@ -1 +1 @”意味着在Git的差异输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在从

  git diff< commitId> ..< commitId>返回的信息中收集数据。 

我碰到 @@ -1 +1 @@



我无法弄清楚告诉我什么。我在Google上搜索了一下,但无济于事。 解决方案

这是一个统一的diff diff标识符。这是由GNU Diffutils 记录


统一输出格式以双行标题开头,如下所示:

 
--- 源自文件修改时间
+++ 至文件修改时间

时间戳看起来像 2002-02-21 23:30:39.942229878 -0800 以指示日期,小数秒的时间和时区。在不支持小数时间戳的主机上省略小数秒。



您可以使用 - label = label 选项;请参阅请参阅替代名称



接下来是一个或多个区别的区别;每个大块显示文件不同的一个区域。统一格式的hunks看起来像这样:

 
@@ 文件行号到文件行号

i> @@
从两个文件中的任一行
从两个文件中的行

如果一个大块只包含一行,则只显示其起始行号。否则,它的行号看起来像 start 。如果大块及其上下文包含两行或多行,其行号看起来像启动计数。否则只会显示其结束行号。一个空白的大块被认为是在大块前面的行处结束。



两个文件的共同行以空格字符开头。两个文件之间实际不同的行在左侧列中有以下指示符中的一个:


  • +

    这里添加了一条线到第一个文件。

  • -

    一行从第一个文件中移除。



I've been collecting data from the information returned from

git diff <commitId>..<commitId>

and I ran into @@ -1 +1 @@

I can't figure out what that's telling me. I've searched a bit on Google but to no avail.

解决方案

It's a unified diff hunk identifier. This is documented by GNU Diffutils.

The unified output format starts with a two-line header, which looks like this:

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

The time stamp looks like 2002-02-21 23:30:39.942229878 -0800 to indicate the date, time with fractional seconds, and time zone. The fractional seconds are omitted on hosts that do not support fractional time stamps.

You can change the header's content with the --label=label option; see See Alternate Names.

Next come one or more hunks of differences; each hunk shows one area where the files differ. Unified format hunks look like this:

@@ from-file-line-numbers to-file-line-numbers @@
 line-from-either-file
 line-from-either-file...

If a hunk contains just one line, only its start line number appears. Otherwise its line numbers look like start,count. An empty hunk is considered to start at the line that follows the hunk.

If a hunk and its context contain two or more lines, its line numbers look like start,count. Otherwise only its end line number appears. An empty hunk is considered to end at the line that precedes the hunk.

The lines common to both files begin with a space character. The lines that actually differ between the two files have one of the following indicator characters in the left print column:

  • +
    A line was added here to the first file.
  • -
    A line was removed here from the first file.

这篇关于什么是“@@ -1 +1 @”意味着在Git的差异输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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