48 points · by keybored · 1y ago · 105 comments
It might be expensive to compute but man it would be so useful.
Edit: TIL about .git-blame-ignore-revs. I am the 1 in 10000 for this one today, thanks.
https://git-scm.com/docs/git-blame
You can configure a default:
git config blame.ignoreRevsFile .git-blame-ignore-revs
GitHub supports it too:https://docs.github.com/en/repositories/working-with-files/u...
I'm really curious though. This is a feature you've wished for: have you never bothered to run `man git-blame`, `git blame --help`, or Google for it? Git has supported it for ages and it's a trivially easy feature to find. Using your own description:
https://www.google.com/search?hl=en&q=git%20skip%20commit%20...
I originally wrote it because I wanted to do a mass-refactoring to llvm-project to change its weird naming convention and "it will mess up git blame" was an objection that was raised. Getting ignore-revs landed took many iterations over several months (thanks Barret!) and at the end of it I felt so drained that I didn't have the energy to do the mass refactoring I originally planned. Oh well. Maybe someday.
Different people have different view preferences.
At least with the . file you have to make 2 separate transactions.
You don't think I looked for it for the first 7-8 years of using Git at least a few times and came up empty? Seems a little uncharitable. Hacker News is a place to learn about stuff, not be chided for missing a point note in a release.
Come on man, you've been using HN for almost as long as I have. Be curious, treat people's comments with charity, continue the life-long learning tradition.
Obligatory XKCD lucky 10,000 link: https://xkcd.com/1053/
https://github.com/git/git/commit/ae3f36dea16e51041c56ba9ed6...
Example: https://gist.github.com/kateinoigakukun/b0bc920e587851bfffa9...
Interesting, I fully expected this blog post to touch on `.git-blame-ignore-revs` as a way to not "pollute" the git history but I'm not sure when that "came out". I found a Github issue from 2021 asking for support to be added to Github so it may just be newer.
How do other people feel about this? Massive code changes across the codebase? Where I work some people are (understandably) concerned about it "ruining" `git blame` or IDE tools to blame. It's not useful to see "Converting to spaces!" on every line you want more context on. Yes, you can step further back but that's always been a little awkward for me (at least in IntelliJ) but maybe I'm missing something. I just find it incredibly helpful to understand the context of why a line was last changed and I'd want to skip over any edits like tabs->spaces.
Supported on Github in 2022: https://github.blog/changelog/2022-03-24-ignore-commits-in-t...
Per https://news.ycombinator.com/item?id=43869828, it appeared August 2019 - so, indeed too late for OP.
e: Also, FTA:
> Blame is not, in fact, permanently ruined. git blame -w ignores whitespace-only changes.
Ah, yes. The 1984 approach to coding
Tabs VS spaces isn't usually very important, but what's more important is that all the stuff is the same way. So if all the other codebases (in the same language) are using tabs, then make everything (in that language) use tabs. Consistency basically :)
The problem with tabs is that they render as different widths in different contexts. For example, Visual Studio shows them as 5 spaces, but Github shows them as 8.
Puts me firmly in the spaces camp now.
The funny thing is that this is why I prefer them. It means I control how indents render rather than the person who wrote the code.
The problem is that everyone touching the project can and often does have different defaults. If you work on a professional setting, specially in legacy projects, you are bound to touch files where your changes comprise mainly of whitespace changes.
People who don't understand tabs are akin to those who don't understand styles: Doomed to laboriously dick around with formatting, and make work for everyone else.
I mean, "just use the IDE's default" isn't really agreeing, unless that's what your entire organization does too, and you all use the same IDE :)
Devs: We need to separate concerns and split the view from the model.
Also devs: Someone might view the code differently!!1!
Maybe Yelp's codebase was otherwise clean, but aside from golang projects (and the Linux kernel) I've come to associate tabs with unreadable slop code. Maybe your experience is different.
However, my conviction has since been tested by Dart which opinionatedly forces you to use two-space indentation. There's no way to disable this and its IDE plugins enforce the style. I just find it so difficult to read, even with Rainbow Brackets. I yearn for Dart to use tabs just so I can configure the tabs to appear as four-space indentation. Or better yet, stop trying to coerce how people write their own code.
https://stackoverflow.blog/2017/06/15/developers-use-spaces-...
Also Vim > Emacs, the new BSG was better than the old BSG, TNG is the best Trek, and all the other hashed-out flamewars of the 90's and 2000's. :)
For every topic of A vs B where A and B are related in some way, no matter how small, there exists an argument C where two people take increasingly opposed positions about which is better.
The only reason I don't use them is because nothing supports/expects/shows them. The alternate history where we properly use them is a world where CSV isn't needed and we're better off for it.
# using tabs with tabsize 4
some_func( eyesore,
blah );
some_func(
eyesore,
blah );
some_func(
eyesore,
blah
);I'm firmly in Team Tab, and I want to arrest any misconception that us Tabbers would do anything as nonsensical as using our precious variable-width tab-stop chars for anything like column-aligning identifiers: we don't.
My very hard and fast rule is that tabs are for only indenting at the block level, while spaces are used for alignment after the initial tab chars; tabs must never be used on a line if preceded by any non-tab char.
Whereas I can't stand always-using-only-spaces-for-indenting-and-alignment - especially because when you're drag-selecting text most editors won't snap your selection to the indent level, so you get RSI in your wrist from having to make micro-movements to make sure you don't select more - or less - spaces than the intended indent. ...or worse: when moving the caret via the keyboard and having to tap your arrow-keys 4 or 8 times per indent instead of just once.
You spaces-only people are totally spaced out, man.
The irony is that this is exactly what tab characters are used for. Have you wondered why they're called tabs? Because they're used for tabulation, making tables. They are intended for aligning columns in a table. Not for indentation.
some_func(
eyesore,
blah
)
which would work just as well with tabs.Many years ago, I used tabs, and set them to two-space indent. The former because the entire point is that tabs carry different semantic information - this is a level of indentation, not just making things align vertically - and allow each developer to set the indentation width to their preference. (The other comment from DaiPlusPlus explains the proper use of tabs, just as I did it.)
The latter because that makes them more square. Aesthetics matter.
I switched mostly out of peer pressure. But one argument I did find convincing is that setting some specific limit on line length - whether it's 72 or 78 or 80 or 100 or anything else - makes sense, and letting people change the amount of indentation defeats that purpose. That is: the guy who likes 8-space indents can't actually have them, because it produces a horizontal scroll for code that "conformed to the style guidelines" when written by the 2-space guy.
But now I alias names, break up complex subexpressions etc. to avoid questions of how to split code across multiple lines - and most lines in my code are nowhere near any such length limit. And I write short functions, so there aren't enough levels of indentation to matter.
And I use 4-space indents, because standards have value after all.
some_func(
verylongarg0,
verylongarg1
);
Which I feel is the most readable option. If you have to break the args into a vertical list, you want to use the least amount of whitespace before each arg. It's also a bit easier to read with every term starting at a tab break. with_long_func_names(
this_scheme,
looks_muddled
);
long_func_name(
tidier,
scheme
);
But my main gripe with tabs is that no one agrees on the width.find . -name *.py -exec expand -t4 '{}' \;
git commit -am'chore: expand all py tabs to spaces'
and this for all branches. Usually also clang-format and dos2unix.
No need for .gitattribute filters. And no magic rewrites, just a commit.
Also, rather than using GitHub Actions to validate if it was followed (after branch was pushed/PR was opened), add it as a Git hook (https://git-scm.com/docs/githooks) to run right before commit, so every commit will be valid and the iteration<>feedback loop gets like 400% faster as you don't have to wait for Actions to finish.
Also: dotnet format is kind of slow, which is why they aren't used where I work.
Yeah, my wording was a bit poor (shouldn't have said "rather"), both are needed, one just helps you fix stuff faster :)
And if you write your hook in a language that can cross-compile and can easily deal with multiple platforms (Go, Rust, NodeJS, many options [probably .net too?]), it's really easy. Just need to make the setup of them part of the onboarding.
Suddenly, one unit test broke. On closer inspection, whoever wrote it put a tab character into a string. I changed the test to use \t.
find -type f -name '*.py' -exec sed -i 's/^\t/ /' {} \+
, until you don't see a diffSeems simpler to adjust that general approach to whatever codebase and replacement.
Uhm, things like this should be enforced in CI. IE, as a rule that must pass in order for a pull request to be merged.