maxcrofts.com

Life After .gitignore

I must admit that I have grown tired of having to write up a .gitignore file for every new repository. It seems such a small thing and yet I never fail to loathe it. Sure, now I could always ask an LLM to automate that task away. But it begs the question why we need it in the first place? Why is it the default? Be it node_modules, .astro, *.obj, or even just build, there’s always something that crops up. And it’s always the same things. So why aren’t we asking more from our tools?

The build example is the big one here. Of course, anyone sensible is going to call CMake like so:

mkdir build
cd build
cmake ../

Thus it makes sense to write a .gitignore with one line saying build, and assume that everyone who clones your repo too is sensible. But what if you’re on macOS and want to have AMD64 and ARM64 builds side-by-side? You may find yourself creating two build directories neither of which follow the project’s prescribed .gitignore. You certainly cannot commit these changes as perhaps nobody but yourself cares about ARM64 support, with every other contributor content to wait out the days of Rosetta 2.

Enter Meson:

meson setup build

Lo and behold you will find no untracked files after running the above. What gives?

Meson sneaks a .gitignore into the directory that it generates. I’m definitely late to the party on this one. This feature shipped in December 2020. Strangely I hadn’t noticed it until literally yesterday. Perhaps I was too used to my routine.

You can certainly make an argument for preserving things like node_modules in narrow circumstances. But why should that be the default for the rest of us? The less ceremony, the better.