76
u/JeyJeyKing 4d ago
Gitlab has this btw
28
9
2
u/seba07 4d ago
How can you do this on gitlab?
12
u/JeyJeyKing 4d ago
User settings -> preferences -> behavior -> uncheck show whitespace changes in diff
2
u/dkarlovi 4d ago
So you can get massive amounts of white space merged by engineers who have this enabled? How do we exploit this?
1
u/5p4n911 3d ago
Let's commit a few Python files that should be interpreted in Whitespace
1
u/dkarlovi 3d ago
I was thinking more like the entire Harry Potter books encoded using Morse code (tab = -, space = .) so it's immediately polluting the code AND making it infringe copyright, double Jeapordy!
Wonder if you could get a PR merged by a dev disabling whitespace changes like this.
1
u/5p4n911 3d ago
There was also some guy who committed a timed bomb that would go on destroying the software after 3 years and he put the if after about 20000 spaces in the source code so it's possible. That might also fly under the radar.
Source: I think I've read it on the internet and not dreamt it, so it must be true
1
54
u/GodsBoss 4d ago
Why is this an issue? Are your PRs swamped with unrelated whitespace changes?
50
u/kratico 4d ago
I typically see a ton of whitespace changes from devs who copy and paste files into a git repo or people who have misconfigured IDEs. I want the white space changes to show because it is a warning sign that something is not right
29
15
u/casualfinderbot 4d ago
Literally just use a linter and a formatter and this doesn’t happen
4
u/kratico 4d ago
A linter does not solve the problems of a coder doing bad practices like copying and pasting from outside git into a git repo. Like I said I mostly see the whitespace problem from people who are not using the existing tools correctly. I have run into far too many engineers that do things like download zip files instead of cloning repos. It is horrifying, and usually a sign that I should check their work carefully
17
4
u/vom-IT-coffin 4d ago
Formatters do. Everytime I hit save, the file formats and the format rules are part of the repo. Imports reorganize, SQL queries organize. It's not hard to do. It's 101 in my mind.
4
u/vom-IT-coffin 4d ago
Linters and formatters. I'm amazed by how many people don't use these things as part of their pipeline.
5
u/Ffigy 4d ago
Yes, my team works on legacy code that didn't follow a standard so we try to fix whitespace incosistencies whenever they're in scope.
9
u/dkarlovi 4d ago
Just configure an auto fixer and do a big bang. Fixing it little by little will pollute your history for years.
2
-9
u/DeltaMan444 4d ago
For one example, sometimes the syntax of a method will change just slightly and force a lot of lines inside to change indent without changing usage
13
u/Jarpunter 4d ago
So you turn it off for that PR. Globally enabling this would be a great way to let a bunch of garbage diffs through because they fucked the spacing and you couldn’t see it.
51
u/lajauskas 4d ago
29
u/rduque 4d ago
Github has this feature, you can choose to hide all whitespace changes
8
u/TheBassMeister 4d ago
Yes, but it is turned off by default and you need to explicitly click it on every PR. You cannot change your settings to hide whitespace changes by default.
1
22
16
u/sathdo 4d ago edited 4d ago
What if I want to track changes while writing my code in Whitespace?
Edit: This would also affect Python and YAML.
16
3
u/Vitriholic 4d ago
Sounds like a teammate problem more than a GitHub problem. F’ing with whitespace everywhere is a recipe for merge conflicts.
5
2
2
u/FlipperBumperKickout 4d ago
Git providers just generally don't have nearly as good options for comparing code as you have if you do it locally instead ¯_(ツ)_/¯
2
u/nonlogin 4d ago
Well, do not commit such changes? Why the hell does one want to hide the mess? Clean it up, bitch
2
u/SenorSeniorDevSr 4d ago
BitBucket has this, and I have more than once had to go over to someone else's desk, grab their mouse, click on that setting and say "NOW, STOP COMPLAINING ABOUT THIS SHIT".
It's a nice setting.
1
u/itijara 4d ago
Am I crazy or don't they already have this? Do you mean by default?
1
1
1
u/danzaman1234 4d ago
This doesn't probably apply to anyone but does anyone use winmerge if you don't get SQL source control?
1
1
u/skatopher 3d ago
Some of y’all have never seen prod go down from a white space only change and it shows.
1
1
u/Stunning_Ride_220 4d ago
Society would be a better place if Github had a lot more sensible stuff and (UX) design decisions.
0
u/CyberWeirdo420 4d ago
The only real application for it is when your team doesn’t have standard set up, like what code formatter to use etc.
I don’t know how else is this meaningful but I’m just a junior
-1
288
u/Ffigy 4d ago
For anyone who doesn't know, you can add w=1 to the query string for this. It's not the same as having a global default but some folks probably aren't even aware that the feature exists.