Repository: jj-vcs/jj

Issue #4154: FR: git log --shortstat alternative
Created: 2024-07-25T14:50:29Z
Is your feature request related to a problem? Please describe.
The git log command has a --shortstat option. It gives a quick overview of how "heavy" a particular commit is and allows a user to visually filter out heavy commits at a glance to the log output. I use it as a signal whether it is time to split current feature branch into multiple PRs.
I want something similar for jj log.
$ git log --graph --oneline --shortstat -n 5
* d6e97883 (HEAD -> main, origin/main, origin/HEAD) cli: port description template to templater
|  11 files changed, 131 insertions(+), 41 deletions(-)
* 5a19eb63 cli: merge description_template_for_*() functions
|  4 files changed, 8 insertions(+), 35 deletions(-)
* 45d16f4b cli: commit, split: set default description to intermediate commit object
|  3 files changed, 9 insertions(+), 15 deletions(-)
* 6395d323 cli: commit, split: pass temporary commit object to description helper
|  3 files changed, 21 insertions(+), 30 deletions(-)
* b9cc61b5 cli: describe: set default description to temporary commit object
|  2 files changed, 7 insertions(+), 12 deletions(-)
Describe the solution you'd like
Given that after d1912bf ("templater: add commit.diff().<format>() methods") we have TreeDiff exposed to the templates, I think this use-case could be covered by exposing changed files/additions/deletions out of it. Thus, a user-configured log template could produce something like this:
$ jj log -r ::main -n 5
◆  yxyrwptq yuya@tcha.org 2024-07-25 13:39:00 main main@origin HEAD@git d6e97883
│  [:11 +131 -41] cli: port description template to templater
◆  knmxwwnk yuya@tcha.org 2024-07-25 13:39:00 5a19eb63
│  [:4 +8 -35] cli: merge description_template_for_*() functions
◆  yxtkoqyl yuya@tcha.org 2024-07-25 13:39:00 45d16f4b
│  [:3 +9 -15] cli: commit, split: set default description to intermediate commit object
◆  nvrptqtt yuya@tcha.org 2024-07-25 13:39:00 6395d323
│  [:3 +21 -30] cli: commit, split: pass temporary commit object to description helper
◆  rxmmrysu yuya@tcha.org 2024-07-25 13:39:00 b9cc61b5
│  [:2 +7 -12] cli: describe: set default description to temporary commit object
Describe alternatives you've considered
Provide a --shortstat option for jj log just like git log does.

Duplicate issue #5272: FR: template method for number of added files in commit
Created: 2025-01-06T00:46:15Z
Is your feature request related to a problem? Please describe.
I think this feature could alleviate some of the issues discussed in #323. The problem is that sometimes you might not notice that a commit starts tracking a new file that wasn't present in the parent, and you might accidentally push it to the remote. This is also related to #4154, but I think it's a different feature (since these file counts are different from the --shortstat counts).
Describe the solution you'd like
If there were a template method or chain of methods (e.g. commit.diff().added_files().len()) that returned the number of new files in the commit, then it would be possible to use the template to display commits which add files differently in the log. For instance, a +N could be added to the log for commits which add new files, and then a user could review the added files to make sure there's nothing that they added accidentally (since for many repos, it's relatively rare to add a new file):
@  ppnpzvyl scott.g.taylor 10 seconds ago a364b1b2 +1
│  (no description set)
◆  skmnsovu Christian.Stoitner 6 hours ago main bcfa2b17
│  added changelog entry for showing untracked files in `jj status`
~

For consistency, we could add the following methods to TreeDiff:

added_files() -> List<String>
modified_files() -> List<String>
deleted_files() -> List<String>
renamed_files() -> List<String>
copied_files() -> List<String>

Describe alternatives you've considered
Instead of being a template method, it could just be a revset for commits which add any new files. Then it would be necessary to use the contained_in(revset) commit template method to show it in a template. I think this isn't ideal, because it wouldn't be possible to show the count of files in the template, and showing the count could be useful (for instance, if a commit adds 500 files, it's often going to be a mistake).
We could add a fileset for added files, and then use commit.diff("added()").files().len() instead. I think this is a bit more complicated though, since it's unclear in what contexts added() would be a valid fileset, and currently all filesets are valid in all contexts I believe.
We could also decide that this isn't necessary, and that the user should use jj status or jj log --summary to check for added files.

Closing comment (2025-01-06T01:48:20Z): Maybe dup of #4154?