【问题标题】:What does git diff mean by `[--]``[--]` 中的 git diff 是什么意思
【发布时间】:2019-12-21 12:46:05
【问题描述】:

我知道下面的命令会显示所有更改,甚至是空格更改。我知道红色的[--] 表示某些内容已被删除。但是什么空间被删除了,我应该以某种方式修复它。我正在尝试修复空格,尤其是行尾,以及 MSYS、PowerShell 和 Linux 环境之间的不一致。

$ git diff --color --word-diff-regex=. -- Pages/Index.cshtml.cs
diff --git a/Pages/Index.cshtml.cs b/Pages/Index.cshtml.cs
index 7518832..3621c0b 100644
--- a/Pages/Index.cshtml.cs
+++ b/Pages/Index.cshtml.cs
@@ -1,4 +1,4 @@
[--]using Google.Apis.Auth.OAuth2;
using Google.Apis.Calendar.v3;
using Google.Apis.Calendar.v3.Data;
using Google.Apis.Services;
@@ -64,7 +64,7 @@ namespace Althing.Pages
            request.TimeMin = DateTime.Now;
            request.ShowDeleted = false;
            request.SingleEvents = true;
            request.TimeMax = DateTime.Now.AddDays(28);[-^M-]
            request.OrderBy = EventsResource.ListRequest.OrderByEnum.StartTime;

            // List events.

【问题讨论】:

    标签: git diff byte-order-mark


    【解决方案1】:

    通过将你的差异复制粘贴到uniname,我得到了这个:

    $ printf '[--]' | uniname
    character  byte       UTF-32   encoded as     glyph   name
            0          0  00005B   5B             [      LEFT SQUARE BRACKET
            1          1  00002D   2D             -      HYPHEN-MINUS
            2          2  00FEFF   EF BB BF               ZERO WIDTH NO-BREAK SPACE
            3          5  00002D   2D             -      HYPHEN-MINUS
            4          6  00005D   5D             ]      RIGHT SQUARE BRACKET
    

    删除的字符是 U+FEFF 零宽度无间隔空格,也称为byte order mark。它是一个不可见的字符,其目的是指示它出现的文件的编码。不建议在 UTF-8 文本中使用,但有时还是会出现在那里。

    【讨论】:

    • 这是在我将 Emacs 中的行尾编码从 dos 更改为 unix 之后出现的,所以这是有道理的。
    • 行尾编码(CR+LF vs LF)与 BOM 是分开的。
    猜你喜欢
    • 1970-01-01
    • 2019-04-03
    • 1970-01-01
    • 2013-05-20
    • 1970-01-01
    • 2012-01-23
    • 1970-01-01
    • 1970-01-01
    • 2012-03-03
    相关资源
    最近更新 更多