AppleWin / AppleWin

Apple II emulator for Windows
GNU General Public License v2.0
715 stars 164 forks source link

Issues with .gitattribute? #487

Open tomcw opened 7 years ago

tomcw commented 7 years ago

Hi Nick,

Over in PR #439 you made a good suggestion of using a .gitattributes file to enforce line-ending consistency for everyone checking out from the AppleWin repo. You said:

It can be configured per repository, which then overrides the user settings. https://help.github.com/articles/dealing-with-line-endings/#platform-all

For reference the current .gitattributes file that I've committed into master looks like this:

# ref: https://help.github.com/articles/dealing-with-line-endings/#platform-all

# Set the default behavior, in case people don't have core.autocrlf set.
# (Check with git config --global --list)
* text=auto

# Declare files that will always have CRLF line endings on checkout.
*.sln text eol=crlf
*.vcproj text eol=crlf
*.vcxproj text eol=crlf
*.vcxproj.filters text eol=crlf
*.bat text eol=crlf

But now if I update (pull) from master or fork (to my personal space)+clone then I get lots of modified files.

EG.:

$ 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:   Make_Distribution.bat
        modified:   libyaml/win32/yaml2010.vcxproj.filters
        modified:   libyaml/win32/yaml2017.vcxproj
        modified:   libyaml/win32/yaml2017.vcxproj.filters
        modified:   test/TestCPU6502/TestCPU6502-vs2017.vcxproj
        modified:   test/TestCPU6502/TestCPU6502-vs2017.vcxproj.filters
        modified:   zip_lib/zip_lib2005.vcproj
        modified:   zip_lib/zip_lib2008.vcproj
        modified:   zip_lib/zip_lib2010.vcxproj
        modified:   zip_lib/zip_lib2010.vcxproj.filters
        modified:   zip_lib/zip_lib2012.vcxproj
        modified:   zip_lib/zip_lib2012.vcxproj.filters
        modified:   zip_lib/zip_lib2017.vcxproj
        modified:   zip_lib/zip_lib2017.vcxproj.filters
        modified:   zlib/zlib-Express2005.vcproj
        modified:   zlib/zlib-Express2008.vcproj
        modified:   zlib/zlib-Express2010.vcxproj
        modified:   zlib/zlib-Express2010.vcxproj.filters
        modified:   zlib/zlib-Express2012.vcxproj
        modified:   zlib/zlib-Express2012.vcxproj.filters
        modified:   zlib/zlib-Express2017.vcxproj
        modified:   zlib/zlib-Express2017.vcxproj.filters

For reference: (desktop PC / AMD Phenom II)

$ git config --global --list
user.name=tomcw
user.email=tomcw@users.noreply.github.com
push.default=matching
diff.renames=copy
  :
core.autocrlf=true

So these are the very files that are the .gitattributes file applies to. This is probably expected, since the line-endings for these files get modified from LF to CRLF. But I was expecting this to be hidden.

I certainly don't want these auto-modified files to be mixed in with files that I'm actually changing, nor do I want every commit/push to be polluting the master repo with these changes!

Any ideas?

(Perhaps this is a one-off and once I commit/push then that's the only time I'll see this. I'll check this idea in my personal fork.)

tomcw commented 7 years ago

(Perhaps this is a one-off and once I commit/push then that's the only time I'll see this. I'll check this idea in my personal fork.)

OK, it looks like it's a one-off.

If I commit+push those modified files to my fork, then cloning again from scratch (by deleting current clone folder), then the status is clean:

$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working tree clean

So are we OK with a single push to master that converts all line-endings for the above .vcproj etc files?

tomcw commented 7 years ago

btw. this is currently blocking any commits to master, since all these .vcproj files are modified. The alternative is to delete the .gitattributes files (or modify it), if I have misunderstood.

sicklittlemonkey commented 7 years ago

Yeah, best to try it in a test branch.

I knew about the option but haven't used it myself. (We're still using SVN at work. ; - )

Cheers, Nick.

tomcw commented 7 years ago

Well the pushed change to my test branch is:

22 changed files with 2,343 additions and 2,343 deletions.

So basically all the above files (.vcproj etc) have, I guess, had their line-endings changed, ie. now stored with LF in the remote GitHub, but CRLF when checked out locally. Whereas previously these files we CRLF in the remote GitHub (maybe?).

This is just a one-off change, and because of the .gitattributes file, then anyone checking out AppleWin will only ever get copies with .vcproj (etc) with CRLF, due to the conversation that .gitattributes enforces. (Assuming I properly understand .gitattributes!)

But what is the problem that we are trying to solve here? None of us (you, me, Michael) had a problem before, and so maybe we are just making work for ourselves... and we just reject the original PR.

tomcw commented 7 years ago

I'm removing .gitattributes for now, as I get different "modified" result on my different machines (desktop vs laptop) - perhaps due to differing git config?

Anyway if it's not consistent for me, then it won't be consistent for others, so until I properly understand the behaviour (done in a dedicated branch or fork, not master) then I'm reverting to .gitattributes setup for now.