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

SourceTree diff treats .sql files as binary

    XMLWordPrintable

    Details

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

      OS: Windows 7

    • Last commented by user?:
      true
    • Symptom Severity:
      Major

      Description

      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

        Attachments

        1. FromSQL.sql
          0.0 kB
        2. FromTEXT.sql
          0.0 kB

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            kyle.mitofsky Kyle Mitofsky
            Participants:
            Votes:
            22 Vote for this issue
            Watchers:
            15 Start watching this issue

              Dates

              Created:
              Updated:
              Last commented:
              9 weeks, 3 days ago