log: add (empty) in front of an empty commit description

This commit is contained in:
Samuel Tardieu 2023-01-14 11:43:23 +01:00
parent 15e04262d8
commit 2ccee54563
8 changed files with 30 additions and 24 deletions

View file

@ -18,6 +18,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
commits, `jj log` now prints the change id in red and puts `??` after it.
Previously, it printed the word "divergent".
* `jj log` prefixes commit descriptions with "(empty)" when they contain no
change compared to their parents.
### New features
* The default log format now uses the committer timestamp instead of the author

View file

@ -133,7 +133,7 @@ in its `jj log` command:
```shell script
$ jj log
@ f39aeb1a0200 martinvonz@google.com 2021-05-23 23:10:27.000 -07:00 192b456b024b
| (no description set)
| (empty) (no description set)
o f63e76f175b9 martinvonz@google.com 2021-05-23 22:13:45.000 -07:00 fb563a4c6d26
| Jujutsu is ready!
o 6a91b4ba16c7 martinvonz@google.com 2021-05-23 22:08:37.000 -07:00 main 080a9b37ff7e
@ -159,11 +159,11 @@ example:
```shell script
$ jj log -r '@ | root | branches()'
@ f39aeb1a0200 martinvonz@google.com 2021-05-23 23:10:27.000 -07:00 192b456b024b
: (no description set)
: (empty) (no description set)
o 6a91b4ba16c7 martinvonz@google.com 2021-05-23 22:08:37.000 -07:00 main 080a9b37ff7e
: cli: make `jj st` show parent commit before working copy commit
o 000000000000 1970-01-01 00:00:00.000 +00:00 000000000000
(no description set)
(empty) (no description set)
```
The `000000000000` commit is a virtual commit that's called the "root commit".
@ -254,7 +254,7 @@ Rebased 1 descendant commits
Working copy now at: e659edc4a9fc (no description set)
$ jj log
@ 461f38324592 martinvonz@google.com 2021-05-26 12:53:08.000 -07:00 e659edc4a9fc
| (no description set)
| (empty) (no description set)
| o 8e6178b84ffb martinvonz@google.com 2021-05-26 12:39:35.000 -07:00 69dbcf76642a
|/ C
o 5548374c0794 martinvonz@google.com 2021-05-26 12:39:30.000 -07:00 576d647acf36

View file

@ -1615,6 +1615,7 @@ fn log_template(settings: &UserSettings) -> String {
" " commit_id.short()
if(conflict, label("conflict", " conflict"))
"\n"
if(empty, label("empty", "(empty) "))
description.first_line()
"\n""#,
);

View file

@ -19,6 +19,7 @@
"divergent" = "red"
"divergent change_id"="red"
"conflict" = "red"
"empty" = "yellow"
"working_copy" = { bold = true }
"working_copy commit_id" = "bright blue"
@ -34,6 +35,7 @@
"working_copy divergent change_id"="bright red"
"working_copy conflict" = "bright red"
"working_copy description" = "bright white"
"working_copy empty" = "bright yellow"
"diff header" = "yellow"
"diff file_header" = "bright white"
"diff hunk_header" = "cyan"

View file

@ -132,7 +132,7 @@ fn test_alias_cannot_override_builtin() {
let stdout = test_env.jj_cmd_success(&repo_path, &["log", "-r", "root"]);
insta::assert_snapshot!(stdout, @r###"
o 000000000000 1970-01-01 00:00:00.000 +00:00 000000000000
(no description set)
(empty) (no description set)
"###);
}

View file

@ -65,33 +65,33 @@ fn test_log_default() {
// Test default log output format
insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["log"]), @r###"
@ ffdaa62087a2 test.user@example.com 2001-02-03 04:05:09.000 +07:00 my-branch 9de54178d59d
| description 1
| (empty) description 1
o 9a45c67d3e96 test.user@example.com 2001-02-03 04:05:08.000 +07:00 4291e264ae97
| add a file
o 000000000000 1970-01-01 00:00:00.000 +00:00 000000000000
(no description set)
(empty) (no description set)
"###);
// Color
let stdout = test_env.jj_cmd_success(&repo_path, &["log", "--color=always"]);
insta::assert_snapshot!(stdout, @r###"
@ ffdaa62087a2 test.user@example.com 2001-02-03 04:05:09.000 +07:00 my-branch 9de54178d59d
| description 1
| (empty) description 1
o 9a45c67d3e96 test.user@example.com 2001-02-03 04:05:08.000 +07:00 4291e264ae97
| add a file
o 000000000000 1970-01-01 00:00:00.000 +00:00 000000000000
(no description set)
(empty) (no description set)
"###);
// Color without graph
let stdout = test_env.jj_cmd_success(&repo_path, &["log", "--color=always", "--no-graph"]);
insta::assert_snapshot!(stdout, @r###"
ffdaa62087a2 test.user@example.com 2001-02-03 04:05:09.000 +07:00 my-branch 9de54178d59d
description 1
(empty) description 1
9a45c67d3e96 test.user@example.com 2001-02-03 04:05:08.000 +07:00 4291e264ae97
add a file
000000000000 1970-01-01 00:00:00.000 +00:00 000000000000
(no description set)
(empty) (no description set)
"###);
}
@ -109,7 +109,7 @@ fn test_log_default_divergence() {
@ 9a45c67d3e96 test.user@example.com 2001-02-03 04:05:08.000 +07:00 7a17d52e633c
| description 1
o 000000000000 1970-01-01 00:00:00.000 +00:00 000000000000
(no description set)
(empty) (no description set)
"###);
// Create divergence
@ -125,7 +125,7 @@ fn test_log_default_divergence() {
| @ 9a45c67d3e96?? test.user@example.com 2001-02-03 04:05:08.000 +07:00 7a17d52e633c
|/ description 1
o 000000000000 1970-01-01 00:00:00.000 +00:00 000000000000
(no description set)
(empty) (no description set)
"###);
// Color
@ -136,6 +136,6 @@ fn test_log_default_divergence() {
| @ 9a45c67d3e96?? test.user@example.com 2001-02-03 04:05:08.000 +07:00 7a17d52e633c
|/ description 1
o 000000000000 1970-01-01 00:00:00.000 +00:00 000000000000
(no description set)
(empty) (no description set)
"###);
}

View file

@ -41,7 +41,7 @@ fn test_obslog_with_or_without_diff() {
o test.user@example.com 2001-02-03 04:05:09.000 +07:00 6fbba7bcb590
| my description
o test.user@example.com 2001-02-03 04:05:08.000 +07:00 eac0d0dae082
my description
(empty) my description
"###);
// There should be no diff caused by the rebase because it was a pure rebase
@ -65,7 +65,7 @@ fn test_obslog_with_or_without_diff() {
| Added regular file file2:
| 1: foo
o test.user@example.com 2001-02-03 04:05:08.000 +07:00 eac0d0dae082
my description
(empty) my description
"###);
// Test `--no-graph`
@ -78,7 +78,7 @@ fn test_obslog_with_or_without_diff() {
test.user@example.com 2001-02-03 04:05:09.000 +07:00 6fbba7bcb590
my description
test.user@example.com 2001-02-03 04:05:08.000 +07:00 eac0d0dae082
my description
(empty) my description
"###);
// Test `--git` format, and that it implies `-p`
@ -115,7 +115,7 @@ fn test_obslog_with_or_without_diff() {
@@ -1,0 +1,1 @@
+foo
test.user@example.com 2001-02-03 04:05:08.000 +07:00 eac0d0dae082
my description
(empty) my description
"###);
}
@ -146,16 +146,16 @@ fn test_obslog_squash() {
| | Added regular file file1:
| | 1: foo
o | test.user@example.com 2001-02-03 04:05:08.000 +07:00 69542c1984c1
| | first
| | (empty) first
o | test.user@example.com 2001-02-03 04:05:07.000 +07:00 230dd059e1b0
/ (no description set)
/ (empty) (no description set)
o test.user@example.com 2001-02-03 04:05:10.000 +07:00 f09a38899f2b
| second
| Modified regular file file1:
| 1 1: foo
| 2: bar
o test.user@example.com 2001-02-03 04:05:09.000 +07:00 579965369703
second
(empty) second
"###);
}

View file

@ -162,13 +162,13 @@ fn test_alias() {
let stdout = test_env.jj_cmd_success(&repo_path, &["log", "-r", "my-root"]);
insta::assert_snapshot!(stdout, @r###"
o 000000000000 1970-01-01 00:00:00.000 +00:00 000000000000
(no description set)
(empty) (no description set)
"###);
let stdout = test_env.jj_cmd_success(&repo_path, &["log", "-r", "identity(my-root)"]);
insta::assert_snapshot!(stdout, @r###"
o 000000000000 1970-01-01 00:00:00.000 +00:00 000000000000
(no description set)
(empty) (no description set)
"###);
let stderr = test_env.jj_cmd_failure(&repo_path, &["log", "-r", "root & syntax-error"]);
@ -264,7 +264,7 @@ fn test_bad_alias_decl() {
.success();
insta::assert_snapshot!(get_stdout_string(&assert), @r###"
o 000000000000 1970-01-01 00:00:00.000 +00:00 000000000000
(no description set)
(empty) (no description set)
"###);
insta::assert_snapshot!(get_stderr_string(&assert), @r###"
Failed to load "revset-aliases."bad"": --> 1:1