Search code examples
gitdiffbyte-order-mark

What does git diff mean by `[--]`


I understand that the command below shows all changes, even whitespace changes. I know that the red [--] indicates something was deleted. But what space was deleted and should I fix it somehow. I'm trying to fix whitespace, particularly line ending, inconsistencies among the MSYS, PowerShell, and Linux environments.

$ 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.

Solution

  • By copy-pasting your diff into uniname, I obtained this:

    $ 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
    

    The removed character is U+FEFF ZERO-WIDTH NO-BREAK SPACE, also known as the byte order mark. It's an invisible character whose purpose is to indicate the encoding of the file it appears in. It's not recommended in UTF-8 text, but sometimes appears there anyway.