(I pronounce it gee-bee-def-jay-jay).
gbdefjj is a diff-editor for jj.
It creates a Git repo in $right and allows to interactively stage changes for the diff.
This is super handy for j split, jj squash -i and friends.
By default, gbdefjj will open Neogit (within Neovim).
The user then interactively stages hunks as if they wanted to select changes to be committed within Git.
But instead of committing, one simply closes Neovim and commits within jj.
Neogit is configured specifically to ease this task.
# ~/.config/jj/config.toml
[ui]
diff-editor = "/path/to/gbdefjj/gbdefjj"
Instead of Neovim+Neogit, one may use anything that allows to stage changes within a Git repo.
Simply dropping into the shell and running Git commands would do.
Setting GBDEFJJ_EDITOR will change the default behavior.
A git add -p-based workflow is provided and can be invoked like this:
GBDEFJJ_EDITOR="git_add_p" jj split
I didn't like the built-in diff-editor and was not satisfied with hunk.nvim. It works fine but I felt it was not as ergonomic as I was used to by using Neogit.
Katalin provided an interactive, patch-based approach.
Their post inspired me to create gbdefjj.
jj-diff is another alternative.
- Since
jjcreates dedicated directories on which the split operates one, any non-commit-related changes will get lost. For example, Neogit allows me to quickly dismiss changes while staging actual changes for a commit. I use this quite often to throw away temporary debug code. When usinggbdefjj, any of this work will not survive the actual split operation.