Uploaded image for project: 'Sourcetree for Windows'
  1. Sourcetree for Windows
  2. SRCTREEWIN-5485

SourceTree diff treats large .sql files as binary

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Medium Medium
    • 3.4.20
    • 1.8.3
    • Git
    • OS: Windows 7

    • Severity 2 - Major

      Source Tree does not allow you to view the diff between a .SQL file, even though the file contents are just plain text. This problem is extended online to stash as well.

      Under the hood, this is likely an issue with git / sql server management studio, but it's manifested in Source Tree and could be handled much better.

      According to the following questions:

      This occurs because:

      SQL files contain a Byte Order Mark (BOM), this is the 0xFEFF sequence you're seeing at the start of the file. Unfortunately these bytes means git treats the file as binary, not text, and so any operations that depend on git, such as generating a diff, aren't going to return what you expect.

      But this is something that SourceTree is minimally doing a bad job at representing this error. Also almost any other external diff tool has no problem comparing the two files, so it's within reason that Source Tree could handle it. Also, on BitBucket Server, there's the option to Transcode Diffs.

      Even a guide on how to setup diffs between sql files would certainly help a non-trivial amount of people

      I attached two very simple SQL files, one created by SSMS and another from Notepad. SSMS encodes UCS-2 LE BOM, while Notepad encodes as ANSI.

      Another strategy might be to setup a commit trigger or filter to remove the BOM

        1. FromSQL.sql
          0.0 kB
        2. FromTEXT.sql
          0.0 kB
        3. image-2024-09-09-16-18-12-370.png
          image-2024-09-09-16-18-12-370.png
          398 kB
        4. image-2024-09-09-16-45-28-774.png
          image-2024-09-09-16-45-28-774.png
          50 kB
        5. image-2024-09-09-16-48-52-927.png
          image-2024-09-09-16-48-52-927.png
          102 kB

              698877135425 Mukesh Kumar (Inactive)
              ae48a9181771 Kyle Mitofsky
              Votes:
              27 Vote for this issue
              Watchers:
              23 Start watching this issue

                Created:
                Updated:
                Resolved: