Jump to content

[Resolved] Unable to diff text files incorrectly recognized as binary


Aki Kanerva

Recommended Posts

Hi there!

I imported a Git repo of a Unity project using fast-import. For some reason, Plastic SCM decided that all .unity, .prefab, .asset and .meta files are binary. This means I can't see quick diffs in the Pending Changes view, and I can't launch the diff viewer using Ctrl+D. All I get is an error message saying that only image formats are supported for binary files.

This leads to two questions:

1. Why didn't Plastic SCM recognize these files as text? Most are normal UTF-8 encoded text files, some are ASCII.

2. How can I force a text diff on two files, even if Plastic SCM thinks they're binary?

Thanks!

Link to comment
Share on other sites

- When you attach a file to Plastic there is a "filetypes.conf" that allows you to customize if Plastic considers a file type binary or text. You can still use this configuration once the fine is already commited:

- From our release notes:

Quote

[New] 7.0.16.2562
filetypes.conf is now used for diffs and merges to check if a file is binary or text.


Until now, the filetypes.conf configuration file was only used by the "add operation" to set newly added files as binary or text.


From now on it will be used to determine if a file is binary or text before running diffs or merges.


Example: suppose scene.config was wrongly added as binary. You can now configure filetypes.conf to consider scene.config as text, so the right text-based diff and merge tool will be selected instead of considering the "bin type" tracked for the file in the repo.
Motivations:
1. This is really useful when you are working with Plastic Cloud, since changing revision types is not allowed there.
2. Our goal is to get rid of the bin/txt tracking as metadata in the repo, and rely only on filetypes.conf.

- You can also use the following command to change the revision type (not available for cloud repos):

dir /S mydir*.unity | cm crt -type=bin

Regards,

Carlos.

Link to comment
Share on other sites

Hi Carlos,

OK, that makes sense, for files that are used frequently.

However, for projects that have data files with many different extensions (or no extensions at all), this is a lot of maintenance work. In the case of files without extensions, you can't even determine whether a file is binary or text, if they have come from different sources. Finally, this falls apart if there are multiple sources for files with a certain extension, one of which generates text files, and the other binary files. For example, .dat is a frequenly-used extension, and depending on the software generating it, it may be text or binary.

Why not have two context menu items, "Diff as binary" and "Diff as text"? This would allow the user to perform a diff quickly without any time-consuming configuration or relying on extensions. Right now, if the user has the wrong configuration, the UI effectively prevents a diff from being made.

Cheers,

-- Aki

Link to comment
Share on other sites

Also, how does filetypes.conf work? The documentation is a bit vague.

I created a filetypes.conf file and placed it in the project root folder, with the following content:

filetypes.conf

*.asset
*.cginc
*.mat
*.meta
*.prefab
*.shader
*.unity

But when I load up the Plastic SCM GUI, nothing has changed - those files are still treated as binary by both the "Show Diffs" option in Pending changes, as well as the Diff context menu commands.

Thanks,

-- Aki

Link to comment
Share on other sites

Quote

Why not have two context menu items, "Diff as binary" and "Diff as text"? This would allow the user to perform a diff quickly without any time-consuming configuration or relying on extensions. Right now, if the user has the wrong configuration, the UI effectively prevents a diff from being made.

The revision is stored in the database as text or binary. If a file that was stored as binary is actually a text file there are two options: change the revisions type in the database. Use the "filetypes.conf" you can explicitly say for a specific file that was stored as binary to be diffed as text. Our goal is to get rid of the bin/txt tracking as metadata in the repo, and rely only on filetypes.conf. 

 

Quote

Also, how does filetypes.conf work? The documentation is a bit vague.

You can check some defails in the following link: https://www.plasticscm.com/book/#_value_matching_pattern_fil

 

Quote

 

These files also contain one pattern per line. Plastic SCM will check the path of each item to find out whether it matches any of the rules to return the assigned value.

Lines in these files will contain rule/value pairs. The separator sequence changes across files:

filetypes.conf uses : as the rule/value separator

 

 
Example 8. filetypes.conf
header.png:bin
README.md:txt

Here, files such as /my-app/wwwroot/img/header.png and /images/header/header.png would be always set as binary, whereas files such as /README.md or /src/doc/README.md would be always set as text. Any other file would have its file type detected from its name and contents.

 

Regards,

Carlos.

 

 

 

Link to comment
Share on other sites

Hi Carlos,

Thanks for the quick reply! I got it working now, thanks for pointing me to the correct docs. :)

I was looking in the Administrator's Guide at https://www.plasticscm.com/documentation/administration/plastic-scm-version-control-administrator-guide#Chapter16:Configurationfiles which only has a brief overview for filetypes.conf and no link to the book.

Cheers,

-- Aki

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...