Posts: 5,241
Joined: Jul 2012
Reputation:
338
2020-01-08, 22:55
(This post was last modified: 2020-01-08, 22:56 by scott967.)
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.
.
Posts: 1,841
Joined: Jul 2012
Reputation:
68
Why not just use vscode, notepad+ or any good editor that allows you to save files with just linefeeds?
Martin
Posts: 5,241
Joined: Jul 2012
Reputation:
338
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.
.
Posts: 12,706
Joined: Nov 2003
Reputation:
129
spiff
Team-Kodi Member
Posts: 12,706
ditch the broken os that think it is a type writer. problem solved.
/runs
Posts: 110
Joined: Jan 2018
Reputation:
7
Hi,
as mentionend already
git config --global core.autocrlf true
is what you want.
The git-bash i use on windows had this enabled by default. It saved me quite often already from pushing \r .
If you want to clean up your local files i can recommend to go to the linux subsystem in win 10 and combine find and sed for that ... something like this ...
find ./ -type f -exec sed -i -e 's/\r//g' {} \;
note... this might need some fideling with the params
BR
Takezo
Posts: 5,241
Joined: Jul 2012
Reputation:
338
I haven't given up on this, but got distracted by other things. I need to get this sorted so I can put up some PRs to provide Py3 updates to some abandoned addons that still are useful in my skin. I should note I've been using github desktop which has come a long ways but maybe this is still beyond it. I have git bash installed so can muck around in git if I have to.
scott s.
.
Posts: 5,241
Joined: Jul 2012
Reputation:
338
Thanks. I've been doing some man reading to better understand what core.autocrlf does. I did find a glitch on my .gitattributes I was using as it was screwing up png files (header has PNG CR LF in it). IIUC the autocrlf should when I switch to a branch show me my text files with cr-lf and when I open them in any text editor I can keep the cr-lf and just when I commit it will actually save the file with just the lf. And I won't see any diffs generated due to line endings. I think I am ready to do some experiments and check it out. I also see now the idea of going into the .git for a repo and making .gitattributes ignored. That I can see for use on a per-repo basis, though I don't think I really need that.
scott s.
.