Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a --notes option to 'move' command #1348

Open
mfulbright opened this issue Jun 19, 2024 · 4 comments
Open

Add a --notes option to 'move' command #1348

mfulbright opened this issue Jun 19, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@mfulbright
Copy link

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.

@arxanas
Copy link
Owner

arxanas commented Jun 21, 2024

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)?

@mfulbright
Copy link
Author

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 moves 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.

@mfulbright
Copy link
Author

I didn't test restack, or any other commit-modifying commands other than what's in my commit (if there are any)

@arxanas
Copy link
Owner

arxanas commented Jun 30, 2024

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:

pub fn post_rebase_in_memory(
effects: &Effects,
git_run_info: &GitRunInfo,
repo: &Repo,
event_log_db: &EventLogDb,
rewritten_oids: &HashMap<NonZeroOid, MaybeZeroOid>,
skipped_head_updated_oid: Option<NonZeroOid>,
options: &ExecuteRebasePlanOptions,
) -> EyreExitOr<()> {

@arxanas arxanas added the enhancement New feature or request label Oct 10, 2024
@arxanas arxanas changed the title [Feature Request] Add a --notes option to 'move' command Add a --notes option to 'move' command Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants