[z88dk-dev] git issue, line endings maybe?

Bridge to the z88dk-developers mailing list
Post Reply
thricenightly
Member
Posts: 28
Joined: Thu Jun 01, 2017 5:46 pm

[z88dk-dev] git issue, line endings maybe?

Post by thricenightly »

I work on Linux, and ever since I made my first fork of the z88dk repo 'git status' has told me I've got changed files which I know I haven't touched. For example, right now I have everything up to date, and I see this:

>git status
On branch master
Your branch is up-to-date with 'origin/master'.

Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)

modified: doc/lib3d.txt
modified: doc/ti.txt
modified: examples/clisp/clisp-spec.txt
modified: examples/msx/README
modified: examples/osca/readme.txt
modified: support/Ace/README
modified: support/aquarius/README
modified: support/c128/README
modified: support/cpc/README
modified: support/m5/README
modified: support/nascom/README.TXT
modified: support/sam/README
modified: support/squsq/sq.txt
modified: support/svi/README
modified: support/ticalc/README
modified: support/trs80/cmd2cas.txt
modified: support/vz/README
modified: support/zx/zxbasdrv/readme.txt

I've not touched any of those.

In the past I've just ignored this, but now it's getting in the way. I've been working on something which has taken weeks, and I've done merges to keep up to date with upstream (i.e. z88dk). Now, when I try to get back my stash'ed work git refuses to merge them because it thinks that list of changes above is going to get lost. It tells me to stash or commit them, but if I try that, even immediately afterwards it thinks those files are still changed.

I *think* this is something to do with line endings. 'git diff' shows the entire file content has changed, even though the lines are identical on each side of the diff. I occasionally see this sort of warning:

>git diff doc/lib3d.txt
warning: CRLF will be replaced by LF in doc/lib3d.txt.
The file will have its original line endings in your working directory.
...

I can see in a hexdump that the file has Windows line endings - 0d 0a. So I think git is trying to tell me that if I commit the file it will change the line endings to Linux style - 0a. I don't want it to do that. I just want it to leave such files alone. So I've read everything I can find on git's "core.autocrlf" config, and have tried setting:

git config --global core.autocrlf input

which is recommended for Linux users, and then rebuilding the index, etc. Nothing I've tried has made any difference.

I notice that all the other files in the repo, other than the ones listed above, have Linux style line endings. These ones are different for some reason. How are other devs dealing with this? Is there some magic git setting or work flow which gets around the problem?

I'm not sure what to do. I can't get rid of the warnings, git thinks files are changed when I've not been near them, and I can't unstash my changes because it won't merge. Help!



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
alvin
Well known member
Posts: 1872
Joined: Mon Jul 16, 2007 7:39 pm

Post by alvin »

We had this issue a while back but it was resolved with .gitattributes:
https://github.com/z88dk/z88dk/blob/mas ... attributes

I'm thinking maybe you cloned before .gitattributes was fixed and are stuck with these cr/lf endings files when the repo now only contains lf endings.

Have you tried deleting (or moving) one of the files and doing another update to see if it will grab it properly and the error goes away? If it works you can just delete the offending files and update to fix.



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
alvin
Well known member
Posts: 1872
Joined: Mon Jul 16, 2007 7:39 pm

Post by alvin »

Actually my local copy of lib3d.txt also has CRLF endings but I don't get the problem you're seeing. If your .gitattributes is up to date and the problem is still there, maybeI can change the line endings and recommit but it would be good to know why there is a problem in the first place.



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
thricenightly
Member
Posts: 28
Joined: Thu Jun 01, 2017 5:46 pm

Post by thricenightly »

Actually my local copy of lib3d.txt also has CRLF endings but I don't get the problem you're seeing. If your .gitattributes is up to date and the problem is still there, maybeI can change the line endings and recommit but it would be good to know why there is a problem in the first place.
Sorry for the delay on this. I figured out a way to get around the problem and moved on. But the fundamental issue is still there.

I tried cloning straight from github into a fresh sandbox. Copy and pasting directly from my terminal:

Code: Select all

derek@... ~ $ pwd
/home/derek
derek@... ~ $ cd tmp
/home/derek/tmp
derek@... ~/tmp $ mkdir z88dk-test
derek@... ~/tmp $ cd !$
cd z88dk-test
/home/derek/tmp/z88dk-test
derek@... ~/tmp/z88dk-test $ git clone https://github.com/z88dk/z88dk.git
Cloning into 'z88dk'...
remote: Counting objects: 154142, done.
remote: Compressing objects: 100% (16/16), done.
remote: Total 154142 (delta 4), reused 7 (delta 4), pack-reused 154122
Receiving objects: 100% (154142/154142), 151.84 MiB | 1.75 MiB/s, done.
Resolving deltas: 100% (115955/115955), done.
Checking connectivity... done.
derek@... ~/tmp/z88dk-test $ ls
z88dk
derek@... ~/tmp/z88dk-test $ cd z88dk/
/home/derek/tmp/z88dk-test/z88dk
warning: CRLF will be replaced by LF in support/Ace/README.
The file will have its original line endings in your working directory.
derek@... ~/tmp/z88dk-test/z88dk (master *=) $
warning: CRLF will be replaced by LF in support/Ace/README.
The file will have its original line endings in your working directory.
derek@... ~/tmp/z88dk-test/z88dk (master *=) $
warning: CRLF will be replaced by LF in support/Ace/README.
The file will have its original line endings in your working directory.
derek@... ~/tmp/z88dk-test/z88dk (master *=) $ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)

modified:   support/Ace/README
modified:   support/aquarius/README
modified:   support/c128/README
modified:   support/cpc/README
modified:   support/m5/README
modified:   support/nascom/README.TXT
modified:   support/sam/README
modified:   support/squsq/sq.txt
modified:   support/svi/README
modified:   support/ticalc/README
modified:   support/trs80/cmd2cas.txt
modified:   support/vz/README
modified:   support/zx/zxbasdrv/readme.txt

no changes added to commit (use "git add" and/or "git commit -a")
warning: CRLF will be replaced by LF in support/Ace/README.
The file will have its original line endings in your working directory.
I was slightly thrown in the middle there when those warnings suddenly started appearing from nowhere! I pressed Enter a couple of times in puzzlement. It appears that the Linux box I was using on AWS happens to have a weird __git_ps1 function in its default prompt which I didn't realise was there. :)

No matter, it seems that the default configuration/attributes/whatever which is currently in the main repo has this issue for Linux users. Can anyone else reproduce this? It's happening for me on my machine at home and this AWS instance.



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Post Reply