-
Notifications
You must be signed in to change notification settings - Fork 376
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: git commit --verbose
equivalent for jj describe
#1946
Comments
jj describe --verbose
git commit --verbose
equivalent for jj describe
This could apply to quite a few commands ( |
Maybe we can have a configurable template for producing that. We currently include something like this:
Maybe that could be replaced by a template like We don't yet have support for including a diff in templates, so we'd need to implement that first. #1354 is slightly related. |
I went looking for this feature, remembered |
Looking for consensus before implementing this:
|
I think config knob is better. It was discussed previously in
Template is preferred because it can solve other problems (such as #1354 and #3385), but it's not easy. I think adding a diff formatting option is also good as a short-term workaround.
Yeah. Perhaps, the default
and |
This implements a building block of "signed-off-by line" jj-vcs#1399 and "commit --verbose" jj-vcs#1946. We'll probably need an easy way to customize the diff part, but I'm not sure if it can be as simple as a template alias function. User might want to embed diffs without "JJ: " prefixes? Perhaps, we can deprecate "ui.default-description", but it's not addressed in this patch. It could be replaced with "default_description" template alias, but we might want to configure default per command. Suppose we add a default "backout_description" template, it would have to be rendered against the source commit, not the newly-created backout commit. The template key is named as "draft_commit_description" because it is the template to generate an editor template. "templates.commit_description_template" sounds a bit odd. There's one minor behavior change: the default description is now terminated by "\n". Closes jj-vcs#1354
This implements a building block of "signed-off-by line" #1399 and "commit --verbose" #1946. We'll probably need an easy way to customize the diff part, but I'm not sure if it can be as simple as a template alias function. User might want to embed diffs without "JJ: " prefixes? Perhaps, we can deprecate "ui.default-description", but it's not addressed in this patch. It could be replaced with "default_description" template alias, but we might want to configure default per command. Suppose we add a default "backout_description" template, it would have to be rendered against the source commit, not the newly-created backout commit. The template key is named as "draft_commit_description" because it is the template to generate an editor template. "templates.commit_description_template" sounds a bit odd. There's one minor behavior change: the default description is now terminated by "\n". Closes #1354
For those who stumble upon this; the nearest equivalent (since #4153) is to add something like this to your config file:
or if you don't want it all the time add an alias using
The most notable deficiency is that you don't get diff highlighting in your text editor like you would with a git commit diff because of the prefixed Edited to fix |
Important note - you almost certainly don't want |
Since #5155, you can now do something like: [template-aliases]
commit_description_verbose = '''
concat(
description,
"\n",
"JJ: This commit contains the following changes:\n",
indent("JJ: ", diff.stat(72)),
"JJ: ignore-rest\n",
diff.git(),
)
'''
[aliases]
dv = ["--config=templates.draft_commit_description=commit_description_verbose", "describe"] |
Thanks. I think we can now close this issue? |
This doesn't highlight changes in Vim like |
I got that working in Neovim with a jjdescription tree-sitter plugin, so it's definitely possible |
Could you give more details? |
This is just based on a few minutes of research, but you might be able to add this jj-description grammar by following treesitter's instuctions on adding parsers. |
Here is a quick and dirty solution for lazy.nvim.
Using the config from #1946 (comment) you should see a colorful diff (assuming you have changes in your working copy) when running $ jj dv There is still room for improvement (e.g. automating the manual copying of query files), but I hope this serves as a good starting point anyway. |
Sorry, was out and about. @pylbrecht got it exactly right. My config is with Nix, so it's probably harder to apply, but I can post the diff of my config if you'd like |
One other thing I did was setting: [templates]
draft_commit_description = '''
concat(
description,
surround(
"\nJJ: This commit contains the following changes:\n", "",
indent("JJ: ", diff.summary()),
),
surround(
"\nJJ: This commit contains the following changes:\n", "",
indent("JJ: ", diff.stat(72)),
),
"\n",
"JJ: ignore-rest\n",
diff.git(),
)
''' so that normal Also worth noting that if you use |
For those using Kakoune, here the simplest but working filetype: https://git.sr.ht/~stacyharper/dotfiles/tree/master/item/.config/kak/autoload/user/jj.kak |
FYI both Vim and Neovim support jj description syntax highlighting, including the diff syntax now vim/vim#16364 No tree-sitter or plugins required. |
Am I correct that this needs latest Neovim master/the upcoming v0.10.4? |
Yes |
Often when writing a commit message, it's useful to be able to see the diff at a glance. Git has
git commit --verbose
, which displays the diff inline in your editor while you're writing the message. This saves having to try to remember what changes you made.I personally use this all the time. I have
which I use for committing almost exclusively.
It would be cool if
jj
supported this as well! I'm not wedded to the name--verbose
, which I think could be clearer (and in fact looking at the help it conflicts with an existing flag with different functionality). Maybe--show-diff
?The text was updated successfully, but these errors were encountered: