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

FR: support for bulk-editing of commit descriptions #3120

Closed
martinvonz opened this issue Feb 22, 2024 · 5 comments · Fixed by #3828
Closed

FR: support for bulk-editing of commit descriptions #3120

martinvonz opened this issue Feb 22, 2024 · 5 comments · Fixed by #3828
Labels
good first issue Good for newcomers polish🪒🐃 Make existing features more convenient and more consistent

Comments

@martinvonz
Copy link
Member

Is your feature request related to a problem? Please describe.

Sometimes you want to edit the descriptions of a whole set of commits.

Describe the solution you'd like

Teach jj describe to accept a revset with multiple commits. If more than one commits is given, open the editor with all descriptions separated by some separator lines. When the user closes the editor, split the descriptions at those separator lines to produce the new descriptions for each commit.

Additional context

I think git-branchless does this.

@PhilipMetzger PhilipMetzger added the polish🪒🐃 Make existing features more convenient and more consistent label Feb 23, 2024
@martinvonz martinvonz added the good first issue Good for newcomers label May 2, 2024
@arxanas
Copy link
Contributor

arxanas commented Jun 3, 2024

@claytonrcarter implemented this for git-branchless. You can find the current implementation here: https://github.com/arxanas/git-branchless/wiki/Command:-git-reword#usage.

For reference, here's the format of the git-branchless multi-message as it appears in the editor:

++ reword abc123
first message

++ reword def456
second message

and so forth. After confirming your edit, git-branchless-reword checks the multi-message contents and verifies that exactly the same input commits are present (no missing or duplicate commits), and then applies all of the message updates.

When the --discard flag is passed, the original commit message is presented in the editor but commented out. The new starting commit message is taken from the Git commit message template, if configured, or otherwise is empty.

Some users have complained that the ++ syntax breaks their editor's built-in behavior around Git commit messages (like I think many editors try to highlight or hard-wrap of the first line, thinking that it's the summary), but jj users already suffer this and have to configure their editors (such as to support the JJ: comments), so probably less of a problem.

@gpanders
Copy link
Member

gpanders commented Jun 3, 2024

but jj users already suffer this and have to configure their editors (such as to support the JJ: comments), so probably less of a problem.

Tangential, but both Vim and Neovim have support for jj syntax now: vim/vim#14733

How would this work with the --verbose FR? If there are multiple revsets, would the diff for each be displayed in the same buffer? Personally, I think I would find this difficult, as it would make finding the start and end of each revision harder if there were also diffs to navigate through.

An alternative would be to start the editor once for each revision, or create separate temp files/buffers for each revision and pass all of them to the editor at once (this way, in an editor like Vim each revision is still in its own buffer, but can be moved between with commands like :next or :bn).

@InCogNiTo124
Copy link
Contributor

An alternative would be to start the editor once for each revision

This was my initial idea, but I think this complicates matters if a user changes their mind mid-change. How can a user give up if they're constantly bombed with $EDITOR opening?

@gpanders
Copy link
Member

gpanders commented Jun 3, 2024

How can a user give up if they're constantly bombed with $EDITOR opening?

git rebase --interactive stops if the editor returns a non-zero exit code. This can be done in Vim with :cq, for instance (not sure if other editors have a similar capability).

@bnjmnt4n
Copy link
Member

bnjmnt4n commented Jun 4, 2024

#3828 implements an initial version which currently opens a separate instance of the editor for each commit. I think having both options (opening multiple editor instances for each commit description and editing multiple commit description within a single editor) definitely have their use cases.

I have a couple of questions to clarify:

  1. Which behavior should be the default, and what option/flag should be used to toggle between them?
  2. What should the jj specific separators be between each commit description?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers polish🪒🐃 Make existing features more convenient and more consistent
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants