This .editorconfig is incompatible with git on windows.#8656
This .editorconfig is incompatible with git on windows.#8656dlang-bot merged 1 commit intodlang:masterfrom
Conversation
|
Thanks for your pull request and interest in making D better, @TurkeyMan! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub fetch digger
dub run digger -- build "master + dmd#8656" |
|
I'm really tired of carrying local changes to this file around in a stash whenever I'm swapping around and working between multiple branches. |
|
Isn't |
|
Absolutely not. It's the default and normal way to interact with git. I've been using git for 6-7 years, and this is the only repo I've ever had trouble with. |
|
My guess is that there's few or no windows contributors that use |
|
When starting using git, autocrlf has been a lot of trouble for me because it caused differences that you could not commit nor revert. Maybe that problem doesn't exist anymore with current versions of git for windows. I think not messing with newlines is the correct way, but VS sometimes isn't helpful: AFAICT if you paste lines from other sources, it might insert CRLF into a text file that has only LF line endings. .editorConfig doesn't seem to help with that. |
|
Right, .editorconfig just makes a big mess. I have to comment out that line, but it's super annoying to stash/pop changes every time I navigate the repo. Windows doesn't use LF, so forcing editors to insert LF among CRLF's whenever you press enter, or paste blocks it just a disaster. Occasionally I forget to comment out the line before doing a bunch of work, and then I have to go back and manually correct the mess! This patch won't break state for LF users either; if you configure git to retain LF when you checkout, competent editors (certainly, any editor that supports .editorconfig) will detect the file's line ending and continue to follow. If you use autocrlf, then all editors work, just as if you're like a normal Windows user ;) |
|
The only Windows editor that doesn't work correctly is Notepad. All other editors work correctly with (Yes, the rule applies to |
I agree, but the .editorConfig is wrong for these files. I think it is probably ok to actually avoid enforcing LF:
The only issue might be creating new files, but the build checks will reject these if committed with CRLF (not enforced for test files, though). |
|
@ZombineDev Thanks for the helpful opinions. This change won't affect anyone except windows users who do use
I'm happy for you. I have been vegetarian for years, and I also ride a bicycle to work... it's clearly the right thing™ to do.
I can't fix it. It's already perfect.
Not an issue, new files are created CRLF, like they should be, and
Everything breaks, and your files are left in a state of ruin >_< |
8dfd889 to
ee81cec
Compare
|
The repo versions of files must be LF terminated, not CRLF. I generally develop on Windows. So how do I manage this? My checkin script uses tolf on the files before sending them to git. Voila, problem solved. https://github.com/dlang/tools/blob/master/tolf.d Please don't check in files with CRLF in them. |
You are playing with your credibility here. |
Oh I burned that guy alive decades ago ;) To be fair though, I'm responding in kind to comments like "The only sane thing is: [...]" .. "the right thing™ to do", when it's just incorrect advice. I'm certain of my claims though; it is objectively correct. I'm not sure it's possible to find your way to a different conclusion if you work it through. |
Yes, git is configured by default to work well on windows. That's why Windows uses CRLF, and denying that creates problems. Text in git repos is de-facto defined to be LF; and as such, Git works perfectly in its intended default configuration, and we don't do anything unusual here that should require special handling. We're just creating a problem where no problem exists.
I suspect you don't use an editorconfig enabled editor, or you have overridden git to checkout with unix endings. And from there, perhaps you must be careful every time you copy&paste text? Or perhaps your editor performs further intelligent translation on copy/paste...
Well you just said it... that's how you resolve this problem. The problem with .editorconfig is that it doesn't apply that logic on commit, it applies it while editing, and you accumulate mess in files you edit as you work (at least, that's true in VS's editor). It also interferes with other aspects of git workflow; since you might perceive your local tree as 'clean' but line endings may be a mess (ie, git status/git diff show 'clean' despite line endings), git then complains when performing various operations about an unclean working tree. If you try and rebase, it initially fails, then you need to reset to fix the line endings, and try again.
I will never do that... nobody would, that's not how git works, even on Windows. The only way you could get a CRLF into a git repo is if someone specifically configures git to commit windows line endings, and in that case, editorconfig can't help you anyway. |
We've had problems from time to time with people checking in CRLF files and generating enormous diffs. I do nearly all my dev on Windows, with pretty much zero line ending problems. The solution is simple - my text editor (MicroEmacs) recognizes LF, CRLF, and CR all as "end of line". When it writes files, on Windows it writes CRLF, on Linux it writes LF, and on the ancient Mac, it writes CR. I've been doing this for decades, it works so darned well I'm amazed that anyone uses an editor that works differently. The only brain-dead program I know of that fails at this is Notepad. But this means that all the files I write on Windows have CRLF. I run As an aside, I never understood what the various git autocrlf settings. The git documentation for it was apparently translated from Klingon by gerbils. After randomly trying a few settings, and wrecking my git repo multiple times, I abandoned it. |
|
Oh, another stupid problem with git autocrlf. git diff loved to show the entire file was different, rendering it useless. It's also why I never use windows git. I push the stuff to a linux box where my git repo lies. Linux software ported to windows never works right, because the porter never gets these right consistently:
DMD, on the other hand, works perfectly with this stuff, because I made damn sure it did :-) |
Default yes, but it's configurable for a reason.
Those two statements are quite contradictory.
While I don't agree that the workflow @TurkeyMan preaches is the One True Workflow, I don't like the idea of enforcing a workflow if there are sane alternatives. |
The process you describe is almost exactly a bespoke implementation of You're welcome to your workflow, but I think you'll find that nobody else will come to that party, and surely, 99.9% of Windows users will operate in the default environment. Either way, this line in
Can you tell how to reproduce that problem? I've never seen anything like that. If I had to imagine how this could be possible, I think it sounds like this:
Assuming this is the scenario, this problem is self-inflicted. But there's a very simple solution here; reset The good news is, all you need to do it
Sure... but what reason? Definitely not for this reason. I can indeed imagine specific scenarios where you might want to deviate from the default; perhaps your build interacts with some tooling which is not line-ending agnostic. As Walters says, he made absolutely sure our entire ecosystem is line-ending agnostic, so that's totally not an issue here. |
I'm not preaching 'a workflow'. There's nothing remarkable or noteworthy about program defaults. I think a good litmus test for any workflows robustness is that it works with default configuration (even notepad). If you want to enhance your workflow to your liking, you're welcome to that, and a good workflow design should support that, but like, if the workflow design fails to account for default configuration, you kinda failed at the gate. And seriously, this is trivial, and not worth any of our time. Apparently this change will affect nobody other than me... I'm tired of juggling stashes every time I have to amend my PR branches. |
Not really. I have a network connection to a linux box, which I ssh into to run git. I don't dev on it, unless there's a problem specific to linux.
No. It was years ago and I got tired of futzing with it. Perhaps it was this: "which will check them out as CRLF" and then they differed from what was in the repository. I hate **** like that.
I don't believe that for a minute :-) And I don't just check in CRLF files. Sometimes its LF files. Sometimes it's files with both CRLF and LF endings. But the result I want is everything in the repository is LF, and everything I check out is LF. Not converted to CRLF. I don't want files in my fork different from the ones in the repository. I really don't know how people put up with that nonsense, it just causes my "red alert" flags to go up. |
|
By the way, does your text editor not have an option to use LF files? |
But you convert to CRLF when you save... so you're still doing the conversion, you're just delaying the conversion. That's the moment where you're shooting yourself int he foot, and only because you didn't do the conversion eagerly.
Of course it does, but that's not the issue here.
I don't want problems with line endings. This I work on a whole lot of projects, and zero of them require this sort of shenanigans. I don't like configuring software, that's just tedious an time consuming. I should be able to format my PC, reinstall the things and get to work. I work across far too many different computers (many of which are corporate controlled and have standard operating environments), to resist the defaults. I don't want to configure software in a non-standard way to interact with a non-standard environment. Configuring my software in a non-standard way would just create friction on every other project, which deserve a lot more of my time. dlang does NOT have a non-standard environment, quite the contrary, it has an absolutely couldn't-be-more-standard environment... all except for this |
On Windows 10 there’s the Subsystem for Linux, you should give it a try. It runs the same ELF binaries as on Linux. |
Sorry, I think I just understood this text... do you mean you 'push' (as in |
|
Since he doesn't use Git on Windows it can't be |
That part I don't want. I don't care for magical conversions. When I get a file from git, I want it to be the same file that is in git. |
Yes. And the 'somehow' is |
This will achieve exactly what you want. |
'Magical conversions' like your editor converting to CRLF on save, or But you're right;
But then you said you just convert it to CRLF anyway...? This is the moment where every line of your diff becomes dirty. It sounds like you could reduce the number of steps in your workflow a whole lot if you ran git from windows. |
git `core.autocrlf` works, and it is default. This setting constantly makes a mess of files, and it's really annoying.
ee81cec to
fa7f530
Compare
|
Why is there here for 2 weeks? |
|
I'm inclined to merge this:
|
|
I agree with Rainers here. I won't be affected by this change and I can't see how anyone would be affected in a negative way. |
dnadlinger
left a comment
There was a problem hiding this comment.
Agreed. This is not an endorsement of autocrlf – which is still the wrong thing to do, and in my experience leads to a life of flames and agony –, but we can remove this piece of auto-configurarion and rely on users to set their editors correctly instead.
Hehe, what was that thing you said about credibility? :P |
The comment is outdated since #8656 was merged.
git
core.autocrlfworks, and it is default. This setting constantly makes a mess of files, and it's really annoying.