Update to .gitattribute file

dawlane

Active Member
CX Code Contributor
Joined
Jun 21, 2017
OK. It's been a while since I've done a bit of work on Cerberus. And last year I was looking into the line ending issue with git as part of the updates I was working on. But I have had to deal with a few personal issues over the last 3 months and haven't yet got round to integrating some of the desktop target changes into the latest Cerberus. So to start with I have posted this version of the .gitattribute file that I was working on. The idea is for the end user to set the global git settings to the correct value for their OS, set the eol of specific files via .gitattributes and preserve files that should not be touched. Git has been known to get it wrong when auto handling files by setting the eol of non text files, thus corrupting them.

Those file types that should be kept as binary will need to be hashed/CRC checked against the original versions released before the eol issue.

Code:
# This file should be treated as a 'work in progress'.
# Merge, filters and union drivers may be need at a later date. See the git documentation on these for an explanation.
# Auto text: Let git handle line conversion for those file types not listed below or set to specific eol/type.
# You should read the documentation for git that relates dealing with global settings.
# On Windows, users should have CRLF>>LF on push LF>>CRLF on pull, so make sure that git config core.autocrlf=true.
# On Linux and OSX should be LF in both directions. You shouldn't need to do anything on these OS's, unless you have changed the default eol.
* text=auto

# Git files: setting these to lf should be ok. Make sure that you use an editor that doesn't change line endings. So NO notepad, use something like Visual Studio Code.
.gitattributes text eol=lf
.gitignore text eol=lf
.gitconfig text eol=lf

# CerberusX/MonkeyX files
# Should cxs/monkey source files have lf line endings?
*.cxs text eol=lf linguist-language=cerberus
*.cerberusdoc text eol=lf
*.monkey text eol=lf
*.monkeydocs text eol=lf

# Source files: Let git decide based on the git global settings. Using text without an eol should use the default core.autocrlf or the OS's git default settings.
# According to one source, the use of the built-in drivers such as 'csharp' should not be use as they may not updated on a regular basis and may cause compile errors.
*.c text
*.cc text
*.cxx text
*.cpp text
*.hpp text
*.h text
*.hpp text
*.hxx text
*.hh text
*.cs text
*.as text
*.htm text
*.html text
*.xhtml text
*.css text
*.json text
*.java text
*.js text
*.md text
*.xml text
*.ini text
*.hlsl text
*.rc text eol=crlf
*.bmx text
# Precompiled headers. Not sure if these should be touched, so treat them as binary files.
*.pch binary

# Visual Studio/Windows known common files convert from lf to crlf to avoid Visual studio warnings.
*.sln text eol=crlf
*.vcxproj text eol=crlf
*.vcxproj.filters text eol=crlf
*.csproj text eol=crlf
*.rex text eol=crlf
*.xaml text eol=crlf
*.appmanifest eol=crlf
*.manifest eol=crlf
# Assuming that pfx is a securty key and shouldn't be messed with.
*.pfx binary

# Xcode
# Check that these are correct and don't all need to be binary. Only pbxproj so far needs to be kept as binary as thats how Xcode handles it even though it is an xml file.
*.pbxproj binary
*.plist text eol=lf
*.xcworkspacedata text eol=lf
*.strings text eol=lf
*.m eol=lf
*.mm text eol=lf
*.xib text eol=lf

# Linux/OSX
*.sh text eol=lf
README text eol=lf
COPYING text eol=lf
CHANGES text eol=lf

# Windows
*.bat text eol=crlf
*.ps1 text eol=crlf
# Should txt cause problems with line endings on other OS's, then remove the eol=crlf and let git global 'text' deal with it.
*.txt text eol=crlf

# Android target.
/targets/android/template/*.keystore binary
/targets/android/template/gradletemplate/gradlew eol=lf

# Image/Fonts/Audio files
# List not complete. If any thing else is added to the repo then these need to be updated.
*.bmp binary
*.png binary
*.jpg binary
*.jpeg binary
*.ico binary
*.icns binary
*.cur binary
*.ttf binary
*.font binary
*.gif binary
*.wav binary
*.ogg binary
*.mp3 binary
*.m4a binary
*.tiff binary
*.caf binary
*.aiff binary

# Other binrary types such as static, shared libraries and document formats.
# List not complete. If any thing else is added to the repo then these need to be updated.
*.pdf binary
*.a binary
*.lib binary
*.so binary
*.dll binary
*.o binary
*.class binary

# Compressed archive files
# List not complete. If any thing else is added to the repo then these need to be updated.
*.gz binary
*.zip binary
*.ZIP binary
*.jar binary
 

MikeHart

Administrator
Staff member
Joined
Jun 19, 2017
Location
Germany
Cool, that will help a lot I guess.
The idea is for the end user to set the global git settings to the correct value for their OS
I am just using Git Desktop without changing anything. Am I doing it wrong?
 

dawlane

Active Member
CX Code Contributor
Joined
Jun 21, 2017
It depends on the OS's and git client that you are using. The client's documentation should have details on how to check and set global settings.

Edit: You should do a few local clones to check that the files types and eols are consistent.
 
Last edited:

dawlane

Active Member
CX Code Contributor
Joined
Jun 21, 2017
I am just using Git Desktop without changing anything. Am I doing it wrong?
It would be a question on how you have your git client set up. Generally when installing Git for Windows on Windows it gives you three options:
  1. Checkout Windows-style, commit Unix-style line endings. Recommended for cross platform projects on Windows ("core.autocrlf=true")
  2. Checkout as-is, commit Unix-style line endings. Recommended for cross platform projects on Unix ("core.autocrlf=input")
  3. Checkout as-is, commit as-is. Not recommended for cross platform ("core.autocrlf=false").
Option one would be recommended for Windows users.
Unix OS's don't normally have core.autocrlf set and as long as you are using an editor such as Visual Studio Code that can set eol, then you don't need to worry about setting core.autocrlf on these OS's.

Edit: On Win 10 I have Git for Windows installed using option 1 and GitKraken set up to use the git bash terminal.
 
Last edited:

dawlane

Active Member
CX Code Contributor
Joined
Jun 21, 2017
I am using this one, Github's own solution.
If I remember Github Desktop should install it's own command line shell that you can use to check and set global values.
You can find the command options here and here.

e.g.
$ git config --global --list
user.email=dawlane@********
user.name=dawlane
core.autocrlf=true
core.editor=code --wait
winupdater.recentlyseenversion=2.15.1.windows.2
 
Last edited:
Top Bottom