Open mfulbright opened 2 weeks ago
Possibly git-branchless should just observe the usual note-rewriting configuration options like https://git-scm.com/docs/git-config#Documentation/git-config.txt-notesrewriteRef
Does note-rewriting work if you enable it and use on-disk rebases (--on-disk
)?
So that's kind of working.
First, here's the config options I set:
$ git config --global --list | grep notes.rewrite notes.rewrite.commit=true notes.rewrite.rebase=true notes.rewriteref=refs/notes/commits
The good news is that setting those options and doing --on-disk move
s is copying the notes over! That's great.
The slight bummer is that, as you seem to have expected, if I don't set --on-disk, the notes are not copied when running move
.
The bad news is that notes are not copied/maintained when doing a git branchless amend
. Even with the notes.rewrite.commit config option set to true.
Watching the output from amend
it seems that it's not doing a git commit --amend
but instead using git reset
to rewrite the commit, so that probably explains why. Though I'm sure you know that and probably know why this isn't working.
reword
also isn't copying/maintaining notes. From output, it looks like it's doing an in-memory rebase for its operations. I don't see a --on-disk flag for the reword
command.
I didn't test restack
, or any other commit-modifying commands other than what's in my commit (if there are any)
Since some of the git-branchless commands just call git rebase
, the note-copying logic in git rebase
handles it in those cases. For in-memory rebases (including git-branchless amend
, which never (?) does an on-disk rebase), there's no opportunity for git rebase
to copyt he notes.
I don't know exactly when/how during the rebase Git copies the notes (and what happens, for example, if you rewrite some commits and then abort the rebase?).
The best place to replicate the Git logic would probably be in post_rebase_in_memory
:
The 'move' command will automatically update all branches in the commits being moved, so that they move with the commits. Which is of course very useful.
It would be great if there was a --notes option that could be passed to the 'move' command that would do the same for commit notes. It would effectively just need to track the original commits and their counterparts after the move, and then run "git notes copy $ORIGINAL_COMMIT $MOVED_COMMIT" for all of them.