Files
jj-vcs-jj/cli/tests/test_commit_command.rs
Vincent Ging Ho Yim cfce146f8f commit: show a hint if --message is not provided and the description is empty
This addresses part of #4414 and implements something akin to what's described in
@arxanas's [suggestion], with the exception that the editor contents don’t need to be
completely cleared, since whether cleared or not it is not obvious whether the user
intended to add an empty description or abort entirely.

[suggestion]: https://github.com/jj-vcs/jj/issues/4414#issuecomment-2359123535

The hint is not shown if an empty description is provided via `--message ""`, since the
user is explicitly bypassing the editor and wants to commit the change directly.

Otherwise, if a user exits the editor with an empty description (notwithstanding any
`JJ:` lines), it could be one of the following cases:

1. The user wants to commit the changes but no longer wants to add a description. The
hint can simply be ignored.

2. The user wants to commit the changes and add a description but accidentally exits the
editor. The second hint shows how to add a description to the parent commit.

3. The user no longer wants to commit the changes. However, a new commit is still
created to maintain consistent behaviour as when an empty description is provided via
the CLI. The first hint shows how to undo the commit.
2025-05-15 13:02:53 +00:00

19 KiB