PR 2730, "Fix" line-endings

Post here if you have re-based and finalised code to integrate into master, which was discussed, agreed to and tested in other forums. You can also submit your PR directly on github.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: PR 2730, "Fix" line-endings

Post by bernd »

We might do not use

Code: Select all

 * text=auto
at all ...

https://github.com/berndhahnebach/FreeC ... ributes#L3

Since we declare all text file types manually we do not need it IMHO. It would be much more save because than only the files explizit declared as text would be normalized by git. If we omit the auto line we even would not need to declare the binary files.

Any git expert around?
ezzieyguywuf
Posts: 656
Joined: Tue May 19, 2015 1:11 am

Re: PR 2730, "Fix" line-endings

Post by ezzieyguywuf »

Incidentally, it looks like gitlab does have an option to ignore whitspace in diffs...in the gui.
2019-12-07-001005_1440x900_scrot.png
2019-12-07-001005_1440x900_scrot.png (75.59 KiB) Viewed 2377 times
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: PR 2730, "Fix" line-endings

Post by triplus »

ezzieyguywuf wrote: Tue Dec 03, 2019 2:31 pm include the necessary .gitattributes info to ensure that anyone using our git repo in the future will have the appropriate git settings to prevent future issues.
How about doing just that for now? New files and existing modified files therefore to always get desired line endings. As for the rest, not to worry about it for now? And therefore for files, where line endings get corrected, to use a -w option in the future (git blame).
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: PR 2730, "Fix" line-endings

Post by triplus »

Reading this:
After you've set the core.autocrlf option and committed a .gitattributes file, you may find that Git wants to commit files that you have not modified. At this point, Git is eager to change the line endings of every file for you.
https://help.github.com/en/github/using ... ne-endings

Didn't test it locally, but once we would introduce .gitattributes file, all (existing) files would automatically be checked anyway, and line-endings to be changed accordingly to the setting?
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: PR 2730, "Fix" line-endings

Post by bernd »

triplus wrote: Tue Dec 10, 2019 8:46 pm
ezzieyguywuf wrote: Tue Dec 03, 2019 2:31 pm include the necessary .gitattributes info to ensure that anyone using our git repo in the future will have the appropriate git settings to prevent future issues.
How about doing just that for now? New files and existing modified files therefore to always get desired line endings. As for the rest, not to worry about it for now? And therefore for files, where line endings get corrected, to use a -w option in the future (git blame).
we will for FEM and Material ATM and than see how it does work ... see PR https://github.com/FreeCAD/FreeCAD/pull/2757
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: PR 2730, "Fix" line-endings

Post by looo »

Seems like an agreement was found regarding handling of line endings. It would be nice to have a proposal/summary to not have to read this full topic and make it easier for new developers to understand there problem/solution.
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: PR 2730, "Fix" line-endings

Post by triplus »

bernd wrote: Tue Dec 10, 2019 10:06 pm we will for FEM and Material ATM and than see how it does work ... see PR https://github.com/FreeCAD/FreeCAD/pull/2757
OK, lets see how it will behave, have seen it got merged. After a while i guess @ezzieyguywuf should prepare a PR, moving the .gitattributes file to root folder? As there seems to be a general consensus, this should be done. Potential cons are therefore manageable (usage of -w option, when it comes to git blame command).
looo wrote: Wed Dec 11, 2019 8:25 am Seems like an agreement was found regarding handling of line endings. It would be nice to have a proposal/summary to not have to read this full topic and make it easier for new developers to understand there problem/solution.
We i guess could, but the way i understand it .gitattributes file will enforce (Unix) line endings, once moved to the root folder. Therefore not much one needs to understand anymore.

P.S. Unless it will turn out, there is still some "vector" open, that can introduce undesired line endings in FreeCAD Git repository.
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: PR 2730, "Fix" line-endings

Post by bernd »

triplus wrote: Thu Dec 12, 2019 9:52 pm
bernd wrote: Tue Dec 10, 2019 10:06 pm we will for FEM and Material ATM and than see how it does work ... see PR https://github.com/FreeCAD/FreeCAD/pull/2757
OK, lets see how it will behave, have seen it got merged. After a while i guess @ezzieyguywuf should prepare a PR, moving the .gitattributes file to root folder?
This is not a good idea IMHO, FEM and Material have used LF line endings for years already. Thus it was just another step in developement of these modules. Other modules might use windows line endings. For them it would be a huge step. Rebasing gets more difficault afterwards. If one knows how to do it with changed line endings, it is simple. If one does not know how to do rebasing with changed line endings it will make him crazy.

My suggestion would be to go step by step, module by module. The module maintainer has to fix upcoming problems, so he should decide if he goes for this change.

But the change is for sure a step in the right direction, because if done, line ending problems will solved forever :D (hopefully :shock: )
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: PR 2730, "Fix" line-endings

Post by bernd »

I had a closer look which modules could use the gitattributes file too. Most modules have dozens of windwos line endings files. As stated before this could lead to huge rebase problems.

But I found three modules on which it would be worth IMHO. The one of Yorik. Means AddonManager, Arch and Draft. Since he does develop on Linux too, his files have LF line endings. Thus only a few files would be converted.

PR made https://github.com/FreeCAD/FreeCAD/pull/2789
yorik wrote: ping
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: PR 2730, "Fix" line-endings

Post by bernd »

AddonManager, Arch, Draft, Fem and Material are normalized to LF and secured by gitattribute file
Post Reply