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

SourceTree diff treats .sql files as binary



    • Type: Bug
    • Status: Long Term Backlog (View Workflow)
    • Priority: Medium
    • Resolution: Unresolved
    • Affects Version/s: 1.8.3
    • Fix Version/s: None
    • Component/s: Git
    • Environment:

      OS: Windows 7

    • Symptom Severity:
      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



            Unassigned Unassigned
            kyle.mitofsky Kyle Mitofsky
            24 Vote for this issue
            18 Start watching this issue