←back to thread

577 points Delgan | 1 comments | | HN request time: 0.2s | source
Show context
xg15 ◴[] No.44349501[source]
Sounds really cool, but how do notes play together with the "history rewriting" features (amend, rebase, etc) where you effectively replace a commit with a modified copy? It sounds as if the notes are attached to a specific commit (or tree or blob) ID. Are git rebase etc smart enough to also copy over the notes to the new commit, or will they just vanish?

What happens on interactive rebases, e.g. if I squash multiple commits into a single one?

I see the same problem with attaching notes to blobs and trees: It's not doing what you might think it does: It feels like it would attach metadata to a file or directory in the repo, but it really attaches the metadata to some specific content:

E.g. if you have a blob that encodes the string "Hello world!" and attach the note to it, would git associate that note with all files that have that content?

Also, if you change one file to "Hello, world!", would it lose the notes?

replies(1): >>44349606 #
rlpb ◴[] No.44349606[source]
> Are git rebase etc smart enough to also copy over the notes to the new commit...

This is configurable. By default, amend and rebase operations will copy them forward. See git-config(1) under `notes.rewrite`.

replies(2): >>44349952 #>>44356810 #
chrishill89 ◴[] No.44356810[source]
By default no copying will be done. While `notes.rewrite.amend` and `notes.rewrite.rebase` are true you also need `notes.rewriteRef` which tells it what notes refs should be rewritten. And it has no value by default. (you can set it to a glob copy over all notes refs)
replies(1): >>44381544 #
1. fnl ◴[] No.44381544[source]
Thanks for the warning! From the git docs:

> Set it to refs/notes/commits to enable rewriting for the default commit notes.

Why wouldn’t that at least be the default? Why is rewriting off by default in the first place?