Friday, 27 June 2025

Brain fart

Sometimes, when I'm programming, I haven't got a good idea of how to do something. What I do have is a large collection of really bad ideas, that I use when I don't have a good idea.

Apparently, good ideas take time. And sometimes they only happen after trying out some really horrendous ideas.

So, I checked the follwing String expression in Kotlin in, and I got some code review comments on it.

"$description $additionalDescription"

The comment was: "put a trim() on the entire thing, as the additionalDescription, which is provided by the user, can be anything (like for example spaces or just empty)".

And I got stuck on that. I came up with something horrendous like the following:

"${(description + additionalDescription).trim()}"

Of course you can immediately see where I went wrong, but once you get invested in the String template solution, sometimes it's hard to break out of that solution again.

The solution I went for was (obviously):

"$description $additionalDescription".trim()

Saturday, 21 June 2025

Git Large File Storage (LFS)

One of my hobby projects is using big files. Github complains about it:

remote: warning: File mrbear/Terrain_PureNature.asset is 58.17 MB; this is larger than GitHub's recommended maximum file size of 50.00 MB
remote: warning: GH001: Large files detected. You may want to try Git Large File Storage1 - https://git-lfs.github.com.

Luckily this is only a warning. The real error happens when trying to push 2GB or bigger files onto the github2.

So, after installing it on my system...

brew install git-lfs

And telling git I wish to use it:

git lfs install

I had to tell it which files were the primary culprits (apparently we do not want ALL files to use LFS).

git lfs track ".png"
git lfs track ".asset"
git lfs track ".fbx"
git lfs track ".unity"

Let's not forget to add those new settings to the repo.

git add Assets/.gitattributes

Apparently this will only work on new files. Existing files in the repo are not changed.

But your could try the command git-lfs-migrate (which will change your repos history) for existing files3.

Addendum

I think it can be argued that, if you need to use LFS a lot for your git repo, git might actually not be the right tool for you.

But I'll leave that argument to smarter people.

References

[1] Git Large File Storage (LFS)
https://git-lfs.github.com
[2] GitHub - About Git Large File Storage
https://docs.github.com/en/repositories/working-with-files/managing-large-files/about-git-large-file-storage
[3] Github Blog - Git LFS 2.2.0 released
https://github.blog/open-source/git/git-lfs-2-2-0-released/