Any git / github gurus? Need help on line endings
#1
I'm trying to update an addon in the kodi xbmc-scripts repo.  IIUC I need to provide a PR to the source repo (in this case it's on XBMC-addons).

My problem is I develop on Windows.  When I fork the repo from XBMC-addons and clone it to my remote I want to create a new branch and add my changes as commits.  But it seems like I run into a problem where the text files on my remote are using CRLF in my editor.  From doing some research one solution seems to be to create a .gitattributes file in my remote repo to force text to eol=lf which I did.  Using .gitattributes it does seem like the files I checkout keep their UNIX LF line endings.  The problem is I end up with a commit of the .gitattributes in my history and can't generate a clean PR from my update branch to the XBMC-addons master.  So how do I avoid getting CRFL introduced in my edited files?  Or just remember to convert the line endings after editing and prior to doing the commit?

scott s.
.
maintainer of skin  Aeon MQ5 mods for post-Gotham Kodi releases:
Matrix
Leia see: 304472
Reply
#2
Why not just use vscode, notepad+ or any good editor that allows you to save files with just linefeeds?

Martin
Reply
#3
You may look at https://help.github.com/en/github/using-...ne-endings -> Global settings for line endings
core.autocrlf true: will checkout lineendings in windows style (CRLF) on your windows machine on checkout and will check them in in linux style (LF) on commit
see more at https://git-scm.com/book/en/v2/Customizi...figuration (search for core.autocrlf)

But be aware this is a global setting, it may effect other git-repos on your computer (especially those which were developed on windows only)
.gitattributes would be less invasive
Reply
#4
Thanks.  As I wrote, I can't figure out a way to use .gitattributes in the Kodi addon development workflow.  It works fine for a personal project.   I was thinking maybe something like core.autocrlf is the way I need to go.  I use np++ (also have ST 3 installed) and at least in np++ it seems like I have to manually select changing line endings from the menu on a per-file basis -- not helpful when doing a global find and replace for example (though I suppose I could also do a find-and-replace on the line endings as well, but needing to do that on every check-out is a pain).

scott s.
.
maintainer of skin  Aeon MQ5 mods for post-Gotham Kodi releases:
Matrix
Leia see: 304472
Reply
#5
ditch the broken os that think it is a type writer. problem solved.

/runs
Reply
#6
(2020-01-14, 16:52)spiff Wrote: ditch the broken os that think it is a type writer. problem solved.

/runs
I think he would have come up with this solution himself, if it was an option for him :-)

But more or less you are right, it's always difficult to handle different line-endings in source, you have to be very careful, especially if you started with one OS and then you switch to another (with different line endings)
Reply
#7
One last option would be:
  • Place your .gitattributes into the git-Folder
  • open the file: .git/info/exclude
  • write following at the end of the file:
    .gitattributes
Explaination:
  • .git/info/exclude is like a .gitignore, but won't be checked in
  • So you can use a .gitattributes put won't mess up with the repo
  • If you ever delete the whole repo (including .git) on your computer and make a new clone you have to manually put .gitattributes and the line in .git/info/exclude again (like already said, they aren't checked in)
Reply
 
Thread Rating:
  • 0 Vote(s) - 0 Average



Logout Mark Read Team Forum Stats Members Help
Any git / github gurus? Need help on line endings00