How to handle line endings in Git

Find and share HowTos to various installations / configurations!
Search

Post Reply
7 posts • Page 1 of 1
fandersen
Posts: 51
Joined: Tue Aug 26, 2014 12:39 pm

How to handle line endings in Git

Post by fandersen »

Hi everyone,

I am using WinCC OA 3.20 P007 in Windows.

I want to version my WinCC OA project in Git.

The default installtion of Git suggests to convert line endings CRLF to LF when committing and converting LF to CRLF when checking out.

Is this behavior OK with WinCC OA or should I better select "Checkout as-is, commit as-is"?

There are no linux developers involved. ;)

BR
Florian

User avatar
hpuchegger
Posts: 86
Joined: Fri Oct 08, 2021 10:38 am

Re: How to handle line endings in Git

Post by hpuchegger »

We use the following settings in ".gitattributes":

Code: Select all

* text=auto
# panel files should not be CRLF changed since LangText format contains number of BYTES to read
*.pnl -text

# config binary
*.tar binary
*.dpl text=auto

auto => CRLF 2 LF
text => no conversion
binary => no conversion

Br, Herbert

fandersen
Posts: 51
Joined: Tue Aug 26, 2014 12:39 pm

Re: How to handle line endings in Git

Post by fandersen »

Hi Herbert,

thank you for your valuable input! :)

I will use this as a starting point and figure out what file types we have and how to them.


BR
Florian

fandersen
Posts: 51
Joined: Tue Aug 26, 2014 12:39 pm

Re: How to handle line endings in Git

Post by fandersen »

Hi Herbert,

in your example you treat *.dpl files as regular text.

But, as there are also *number of bytes to read*, couldn't it happen there too, that turning LF to CRLF breaks something?

BR
Florian

gschijndel
Posts: 373
Joined: Tue Jan 15, 2019 3:12 pm

Re: How to handle line endings in Git

Post by gschijndel »

The dpl file is a tab separated values file. There should be no number of bytes to read in it.

But when you are busy with the .gitattributes you should also consider to enable git-lfs for binary files. It makes cloning faster due to a smaller repo size.
In case linguist is used to determine the language (by gitlab/github for example) you can tell it to use another language for the scripts and libraries.

Code: Select all

# Use git-lfs for these file types
*.dll	filter=lfs diff=lfs merge=lfs -crlf
*.exe	filter=lfs diff=lfs merge=lfs -crlf
*.pdf	filter=lfs diff=lfs merge=lfs -crlf
*.so	filter=lfs diff=lfs merge=lfs -crlf

# Prevent that as programming language visual basic is shown
*.ctl linguist-language=C++

fandersen
Posts: 51
Joined: Tue Aug 26, 2014 12:39 pm

Re: How to handle line endings in Git

Post by fandersen »

Hi gschijndel,

I have checked the dpl format. And you are right. In the format "Regular export", there are no "number of bytes to read" in it. By default, the ASCII file is already created with CRLF eol by the ASCII manager.

It is different for Format 2 (Multi language export) of the ASCII export. We use it for some special cases. There you have "number of bytes to read". But I could not get RAIMA to store translations with line breaks. So I guess I don't need to worry about corruption.

About, git-lfs: Yeah we heard about it. Git stores the binary files on the Git LFS server and puts a pointer to the file inside the repo instead. We definitively check that out, thanks!

BR
Florian

User avatar
leoknipp
Posts: 2926
Joined: Tue Aug 24, 2010 7:28 pm

Re: How to handle line endings in Git

Post by leoknipp »

The ASCII format 2 was used in the past as it was still possible to have language dependent names for DP types and datapoints.
As it is hard to read and not easy to edit we recommend not to use this format.

Best Regards
Leopold Knipp
Senior Support Specialist

Post Reply
7 posts • Page 1 of 1