Log view shows some html files as binary files, other html files as text files

In my history view, when I look at some .htm files of my (e.g.) initial commit, they show up in the right pane as binary files, with some buttons "Preview 'After'", "Open 'Before'" (which is grayed out), and an "Open 'After'".

Below that I can see some sort of mini browser window (a la Preview that would show up when pressing the space bar in the finder).

Other .htm files in that same commit just show up with the number of lines added, and the source code shown.

Both types show a 'Reverse' button.

Why don't all my .htm files show up as plain text files, like they do in File Status view?

2 answers

1 accepted

1 vote
Answer accepted

The ones that show up as binary are probably in a non-UTF8 text encoding, maybe UTF-16. Neither git nor hg can display text diffs for UTF-16 content, only UTF8 - they always treat anything else as binary, and therefore so does SourceTree.

file -I my_page.htm results in

my_page.htm: text/html; charset=binary

I think this encoding resulted from the document having been stored/retrieved by the user to/from an (XML-)database and/or confusing BLOBs and CLOBs. I'll contact him to clear this further up. Thanks for your answer.

I'm having the same problem. My .html file is definitely utf-8. If duplicate the file, the duplicate shows in SourceTree as text. If I delete the original file and rename the duplicate to match the original name, it shows up as binary again.

SourceTree used to allow diffing utf-16 in UI but it does not work anymore. It was accomplished using the following in .gitattributes:

[attr]utf16 diff merge -crlf
*.sj utf16

I have an old version installed (.9.2.3) where it would read this and would display in the viewer panel. Can this be fixed? I'd rather not convert the files to UTF-8 or stay on the old version. This declaration works fine for other external viewers, it tells git to treat the file as text.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Oct 23, 2018 in Sourcetree

Tip from the team: configure your repos for hosting goodness!

Supported Platforms macOS Windows We recently introduced support for additional hosting services such as GitHub Enterprise, GitLab (Cloud, Community Edition, Enterprise Edition), and...

1,224 views 4 2
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you