Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!
Commit descriptions are optional in jj by design.
Unlike Git,
leaving the commit message blank in the editor does NOT abort jj commit.
However,
jj does abort the command if the editor exits with a non-zero code
(e.g., :cq in Vim / Neovim).
A practical way is to configure a wrapper script as jj’s ui.editor,
which exits with an error if the commit message is empty
(ignoring jj’s JJ: comment lines).
For example,
create a script ~/.local/bin/jj-editor-check.fish.
#!/usr/bin/env fish
set -l file $argv[1]
# Use the first non-blank one of $VISUAL, $EDITOR and vim
set -l editor (string match -rv '^\s*$' -- $VISUAL $EDITOR vim)[1]
# Split to allow editor commands with arguments (e.g., "code --wait")
set -l cmd (string split -n ' ' -- $editor)
$cmd $file; or exit $status
# Check whether the file contains any non-comment, non-whitespace text
if not sed '/^JJ: ignore-rest$/,$d' $file | grep -v '^JJ:' | grep -q '[^[:space:]]'
echo "Aborting due to empty commit message." >&2
exit 1
endMake it executable.
chmod +x ~/.local/bin/jj-editor-check.fishAnd configure jj to use it
(~ is not expanded in ui.editor, so use an absolute path).
jj config set --user ui.editor /home/<user>/.local/bin/jj-editor-check.fishNotes:
Do NOT set
$VISUAL/$EDITORto the script itself (infinite recursion). And$JJ_EDITOR(if set) overridesui.editorand bypasses the script.The script applies to every command that opens
ui.editor, e.g.,jj commit,jj describe,jj splitandjj squash(when combining messages). Diff editors and-m(e.g.,jj describe -m "") are not affected.If a commit with an empty message is created anyway, run
jj undoimmediately to roll it back, or add a message later usingjj describe.