Hacker News new | ask | show | jobs
by mfontani 1296 days ago
I've tried to use git notes over the years but unfortunately notes are tied to a specific commit hash. It's a blessing and a curse.

Works great for some types of review system, or for "tagging" things related to deploy. Notes on commits on the master/main branch, which doesn't get rebased? Awesome thing, they work.

But you can't as easily use them on branches: the moment a branch whose commits had notes is rebased, and SHAs change, good-bye notes associated with the "previous" SHAs :/

3 comments

Do you need to `git config notes.rewriteRef refs/notes/commits`[1]?

[1] https://stackoverflow.com/a/14601464/96588

I had no idea this even existed, and I've run into this problem with notes myself! This seems like something that should be a default.
Seems like a standard git thing: have a process that works in a specific, but not a “helpful” way and also have a undiscoverable setting to configure said process.

Is that why people keep building UIs and wrappers for git?

Having lots of config is fine, even good, if you ship sane defaults. Frankly most OSS flunks this, and git is one of the biggest offenders.
Git has so many users that changing defaults is pretty tricky. They have done it in the past but usually over multiple release cycles with a deprecation window.
Maybe they should introduce an option to configure which set of defaults is used.

e.g.

defaults=traditional adopts current defaults (that maximise backward compatibility)

defaults=latest adopts latest recommended defaults (better out-of-box user experience, but may break things which depend on the traditional settings)

Then at least there is only one setting to change to get sane defaults.

Maybe even, defaults=VERSION to give you latest defaults as per that version.

Ah yes, like how nginx’s defaults still like to pretend it’s early 2000s, everyone uses dialup, and nobody could possibly want their website to serve more than a handful of requests per hour.
Like Apache's default settings working well for a site that gets no more than one visitor a minute.
Yep. The default options are usually the wrong ones.
Depends. You can also see those as notes and you want to have them go away after rebase automatically so you have invalidation built in (e.g. preparing changes).
My guess is that it was originally an oversight and this option was added later, but turned off by default to avoid a "breaking change". Would be interesting to dig through the changelogs and commit history to see what the story was.
Yes, it is totally possible to guess it this way. From top of my head reference rewriting while rebase is older thought, but I'd be clueless about it apart from that rebasing is for rewriting commit references in the first place. And everything else - including git-note references - needs to be explicitly configured from that default behaviour. Which follows your argument in a broader sense, as per default no other refs are expected to get rewritten and therefore it shouldn't be different for git-notes, even if they were introduced with the configuration option to rewrite them in the first place.
Not completely sure but seems like a problem that could be solved using pre-rebase hook.
Another reason to never rebase.