ok/jj
1
0
Fork 0
forked from mirrors/jj

log: move commit ID off to the right

We have talked about showing the commit ID only for divergent changes
because it's generally easier to work with the change ID, and it's
less likely to result in a divergent change. However, it's useful to
have the commit ID available for pasting into e.g. a commit message or
the GitHub UI. To try to steer users towards using the change ID, this
commit moves the commit ID off to the right in the log output.

I put it just after the "divergent" field, because that makes it close
to how I imagine it would look if we decided to hide the commit ID
except for divergent changes. I was thinking that could be rendered as
"divergent (abc123)". So if we add config to hide the commit ID, then
it would be rendered almost the same for divergent commits (just with
the added parentheses). It would also make sense to replace the
"divergent" field by a question mark on the change ID, since change
IDs basically behave like branches. If we do that, then the placement
of the commit ID I picked in this commit does not make sense.
This commit is contained in:
Martin von Zweigbergk 2022-11-13 10:01:11 -08:00 committed by Martin von Zweigbergk
parent f86455a452
commit 50ba571527
11 changed files with 66 additions and 60 deletions

View file

@ -49,6 +49,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* (#254) Branches that have a different target on some remote than they do
locally are now indicated by an asterisk suffix (e.g. `main*`) in `jj log`.
* The commit ID was moved from first on the line in `jj log` output to close to
the end. The goal is to encourage users to use the change ID instead, since
that is generally more convenient, and it reduces the risk of creating
divergent commits.
### Fixed bugs
* (#463) A bug in the export of branches to Git caused spurious conflicted

Binary file not shown.

Before

Width:  |  Height:  |  Size: 136 KiB

After

Width:  |  Height:  |  Size: 136 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 251 KiB

After

Width:  |  Height:  |  Size: 250 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 297 KiB

After

Width:  |  Height:  |  Size: 301 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 265 KiB

After

Width:  |  Height:  |  Size: 264 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 270 KiB

After

Width:  |  Height:  |  Size: 271 KiB

View file

@ -127,19 +127,20 @@ You're probably familiar with `git log`. Jujutsu has very similar functionality
in its `jj log` command:
```shell script
$ jj log
@ 192b456b024b f39aeb1a0200 martinvonz@google.com 2021-05-23 23:10:27.000 -07:00
@ f39aeb1a0200 martinvonz@google.com 2021-05-23 23:10:27.000 -07:00 192b456b024b
| (no description set)
o fb563a4c6d26 f63e76f175b9 martinvonz@google.com 2021-05-23 22:13:45.000 -07:00
o f63e76f175b9 martinvonz@google.com 2021-05-23 22:13:45.000 -07:00 fb563a4c6d26
| Jujutsu is ready!
o 080a9b37ff7e 6a91b4ba16c7 martinvonz@google.com 2021-05-23 22:08:37.000 -07:00 main
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
```
The `@` indicates the working-copy commit. The first hash on a line is the
commit ID. The second hash is a "change ID", which is an ID that follows the
commit as it's rewritten (similar to Gerrit's Change-Id). You can give either
hash to commands that take revisions as arguments. We will generally prefer
change IDs because they stay the same when the commit is rewritten.
"change ID", which is an ID that follows the commit as it's rewritten (similar
to Gerrit's Change-Id). The second hash is the commit ID, which changes when you
rewrite the commit. You can give either hash to commands that take revisions as
arguments. We will generally prefer change IDs because they stay the same when
the commit is rewritten.
By default, `jj log` list your local commits, with some remote commits added for
context. The `~` indicates that the commit has parents that are not included
@ -151,11 +152,11 @@ all commits pointed to by branches. We can combine expressions with `|` for
union, `&` for intersection and `~` for difference. For example:
```shell script
$ jj log -r '@ | root | branches()'
@ 192b456b024b f39aeb1a0200 martinvonz@google.com 2021-05-23 23:10:27.000 -07:00
@ f39aeb1a0200 martinvonz@google.com 2021-05-23 23:10:27.000 -07:00 192b456b024b
: (no description set)
o 080a9b37ff7e 6a91b4ba16c7 martinvonz@google.com 2021-05-23 22:08:37.000 -07:00 main
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 000000000000 1970-01-01 00:00:00.000 +00:00
o 000000000000 1970-01-01 00:00:00.000 +00:00 000000000000
(no description set)
```
@ -184,13 +185,13 @@ Working copy now at: fd571967346e B2
$ jj new -m C; echo c > file2
Working copy now at: 4ae1e0587eef C
$ jj log
@ 1769bdaa8d6d 8e6178b84ffb martinvonz@google.com 2021-05-26 12:39:35.000 -07:00
@ 8e6178b84ffb martinvonz@google.com 2021-05-26 12:39:35.000 -07:00 1769bdaa8d6d
| C
o de5690380f40 5548374c0794 martinvonz@google.com 2021-05-26 12:39:30.000 -07:00
o 5548374c0794 martinvonz@google.com 2021-05-26 12:39:30.000 -07:00 de5690380f40
| B2
o 47e336632333 ce619d39bd96 martinvonz@google.com 2021-05-26 12:39:20.000 -07:00
o ce619d39bd96 martinvonz@google.com 2021-05-26 12:39:20.000 -07:00 47e336632333
| B1
o 661432c51c08 cf49e6bec410 martinvonz@google.com 2021-05-26 12:39:12.000 -07:00
o cf49e6bec410 martinvonz@google.com 2021-05-26 12:39:12.000 -07:00 661432c51c08
~ A
```
@ -202,13 +203,13 @@ Rebased 2 commits
Working copy now at: 9195b6d2e8dc C
Added 0 files, modified 1 files, removed 0 files
$ jj log
@ 66274d5a7d2d 8e6178b84ffb martinvonz@google.com 2021-05-26 12:39:35.000 -07:00 conflict
@ 8e6178b84ffb martinvonz@google.com 2021-05-26 12:39:35.000 -07:00 66274d5a7d2d conflict
| C
o 0c305a9e6b27 5548374c0794 martinvonz@google.com 2021-05-26 12:39:30.000 -07:00 conflict
o 5548374c0794 martinvonz@google.com 2021-05-26 12:39:30.000 -07:00 0c305a9e6b27 conflict
| B2
| o 47e336632333 ce619d39bd96 martinvonz@google.com 2021-05-26 12:39:20.000 -07:00
| o ce619d39bd96 martinvonz@google.com 2021-05-26 12:39:20.000 -07:00 47e336632333
|/ B1
o 661432c51c08 cf49e6bec410 martinvonz@google.com 2021-05-26 12:39:12.000 -07:00
o cf49e6bec410 martinvonz@google.com 2021-05-26 12:39:12.000 -07:00 661432c51c08
~ A
```
@ -246,15 +247,15 @@ $ jj squash
Rebased 1 descendant commits
Working copy now at: e659edc4a9fc (no description set)
$ jj log
@ e659edc4a9fc 461f38324592 martinvonz@google.com 2021-05-26 12:53:08.000 -07:00
@ 461f38324592 martinvonz@google.com 2021-05-26 12:53:08.000 -07:00 e659edc4a9fc
| (no description set)
| o 69dbcf76642a 8e6178b84ffb martinvonz@google.com 2021-05-26 12:39:35.000 -07:00
| o 8e6178b84ffb martinvonz@google.com 2021-05-26 12:39:35.000 -07:00 69dbcf76642a
|/ C
o 576d647acf36 5548374c0794 martinvonz@google.com 2021-05-26 12:39:30.000 -07:00
o 5548374c0794 martinvonz@google.com 2021-05-26 12:39:30.000 -07:00 576d647acf36
| B2
| o 47e336632333 ce619d39bd96 martinvonz@google.com 2021-05-26 12:39:20.000 -07:00
| o ce619d39bd96 martinvonz@google.com 2021-05-26 12:39:20.000 -07:00 47e336632333
|/ B1
o 661432c51c08 cf49e6bec410 martinvonz@google.com 2021-05-26 12:39:12.000 -07:00
o cf49e6bec410 martinvonz@google.com 2021-05-26 12:39:12.000 -07:00 661432c51c08
~ A
```
@ -292,15 +293,15 @@ an operation. By default, it will undo the most recent operation. Let's try it:
$ jj undo
Working copy now at: 41f0d2289b56
$ jj log
@ 41f0d2289b56 b1e3a4afde5e martinvonz@google.com 2021-05-26 12:52:39.000 -07:00
@ b1e3a4afde5e martinvonz@google.com 2021-05-26 12:52:39.000 -07:00 41f0d2289b56
| (no description set)
| o 66274d5a7d2d 8e6178b84ffb martinvonz@google.com 2021-05-26 12:39:35.000 -07:00 conflict
| o 8e6178b84ffb martinvonz@google.com 2021-05-26 12:39:35.000 -07:00 66274d5a7d2d conflict
|/ C
o 0c305a9e6b27 5548374c0794 martinvonz@google.com 2021-05-26 12:39:30.000 -07:00 conflict
o 5548374c0794 martinvonz@google.com 2021-05-26 12:39:30.000 -07:00 0c305a9e6b27 conflict
| B2
| o 47e336632333 ce619d39bd96 martinvonz@google.com 2021-05-26 12:39:20.000 -07:00
| o ce619d39bd96 martinvonz@google.com 2021-05-26 12:39:20.000 -07:00 47e336632333
|/ B1
o 661432c51c08 cf49e6bec410 martinvonz@google.com 2021-05-26 12:39:12.000 -07:00
o cf49e6bec410 martinvonz@google.com 2021-05-26 12:39:12.000 -07:00 661432c51c08
~ A
```
As you can perhaps see, that undid the `jj squash` invocation we used for
@ -333,11 +334,11 @@ Working copy now at: 9d97c5018b23 ABC
$ jj new -m ABCD; printf 'A\nB\nC\nD\n' > file
Working copy now at: c5a985bc3f41 ABCD
$ jj log
@ 687009839bae 874f2d307594 martinvonz@google.com 2021-05-26 14:36:38.000 -07:00
@ 874f2d307594 martinvonz@google.com 2021-05-26 14:36:38.000 -07:00 687009839bae
| ABCD
o ad9b1ce3b5d0 2bbc0c1eb382 martinvonz@google.com 2021-05-26 14:36:26.000 -07:00
o 2bbc0c1eb382 martinvonz@google.com 2021-05-26 14:36:26.000 -07:00 ad9b1ce3b5d0
| ABC
o a355fb177b21 3680117711f5 martinvonz@google.com 2021-05-26 14:36:05.000 -07:00
o 3680117711f5 martinvonz@google.com 2021-05-26 14:36:05.000 -07:00 a355fb177b21
~ abc
```

View file

@ -1994,8 +1994,7 @@ fn log_template(settings: &UserSettings) -> String {
// TODO: define a method on boolean values, so we can get auto-coloring
// with e.g. `conflict.then("conflict")`
let default_template = r#"
commit_id.short()
" " change_id.short()
change_id.short()
" " author.email()
" " label("timestamp", author.timestamp())
if(branches, " " branches)
@ -2003,6 +2002,7 @@ fn log_template(settings: &UserSettings) -> String {
if(working_copies, " " working_copies)
if(is_git_head, label("git_head", " HEAD@git"))
if(divergent, label("divergent", " divergent"))
" " commit_id.short()
if(conflict, label("conflict", " conflict"))
"\n"
description.first_line()

View file

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

View file

@ -107,7 +107,7 @@ fn test_init_git_external() {
// Check that the Git repo's HEAD got checked out
let stdout = test_env.jj_cmd_success(&repo_path, &["log", "-r", "@-"]);
insta::assert_snapshot!(stdout, @r###"
o 8d698d4a8ee1 d3866db7e30a git.user@example.com 1970-01-01 01:02:03.000 +01:00 my-branch HEAD@git
o d3866db7e30a git.user@example.com 1970-01-01 01:02:03.000 +01:00 my-branch HEAD@git 8d698d4a8ee1
~ My commit message
"###);
}
@ -150,7 +150,7 @@ fn test_init_git_colocated() {
// Check that the Git repo's HEAD got checked out
let stdout = test_env.jj_cmd_success(&repo_path, &["log", "-r", "@-"]);
insta::assert_snapshot!(stdout, @r###"
o 8d698d4a8ee1 d3866db7e30a git.user@example.com 1970-01-01 01:02:03.000 +01:00 my-branch HEAD@git
o d3866db7e30a git.user@example.com 1970-01-01 01:02:03.000 +01:00 my-branch HEAD@git 8d698d4a8ee1
~ My commit message
"###);
}

View file

@ -34,13 +34,13 @@ fn test_obslog_with_or_without_diff() {
let stdout = get_log_output(&test_env, &repo_path, &["obslog"]);
insta::assert_snapshot!(stdout, @r###"
@ 1daafc17fefb test.user@example.com 2001-02-03 04:05:08.000 +07:00
@ test.user@example.com 2001-02-03 04:05:08.000 +07:00 1daafc17fefb
| my description
o 813918f7b4e6 test.user@example.com 2001-02-03 04:05:08.000 +07:00 conflict
o test.user@example.com 2001-02-03 04:05:08.000 +07:00 813918f7b4e6 conflict
| my description
o 8f02f5470c55 test.user@example.com 2001-02-03 04:05:08.000 +07:00
o test.user@example.com 2001-02-03 04:05:08.000 +07:00 8f02f5470c55
| my description
o c8ceb219336b test.user@example.com 2001-02-03 04:05:08.000 +07:00
o test.user@example.com 2001-02-03 04:05:08.000 +07:00 c8ceb219336b
my description
"###);
@ -48,43 +48,43 @@ fn test_obslog_with_or_without_diff() {
// (even even though it resulted in a conflict).
let stdout = get_log_output(&test_env, &repo_path, &["obslog", "-p"]);
insta::assert_snapshot!(stdout, @r###"
@ 1daafc17fefb test.user@example.com 2001-02-03 04:05:08.000 +07:00
@ test.user@example.com 2001-02-03 04:05:08.000 +07:00 1daafc17fefb
| my description
| Resolved conflict in file1:
| 1 1: <<<<<<<resolved
| 2 : %%%%%%%
| 3 : +bar
| 4 : >>>>>>>
o 813918f7b4e6 test.user@example.com 2001-02-03 04:05:08.000 +07:00 conflict
o test.user@example.com 2001-02-03 04:05:08.000 +07:00 813918f7b4e6 conflict
| my description
o 8f02f5470c55 test.user@example.com 2001-02-03 04:05:08.000 +07:00
o test.user@example.com 2001-02-03 04:05:08.000 +07:00 8f02f5470c55
| my description
| Modified regular file file1:
| 1 1: foo
| 2: bar
| Added regular file file2:
| 1: foo
o c8ceb219336b test.user@example.com 2001-02-03 04:05:08.000 +07:00
o test.user@example.com 2001-02-03 04:05:08.000 +07:00 c8ceb219336b
my description
"###);
// Test `--no-graph`
let stdout = get_log_output(&test_env, &repo_path, &["obslog", "--no-graph"]);
insta::assert_snapshot!(stdout, @r###"
1daafc17fefb test.user@example.com 2001-02-03 04:05:08.000 +07:00
test.user@example.com 2001-02-03 04:05:08.000 +07:00 1daafc17fefb
my description
813918f7b4e6 test.user@example.com 2001-02-03 04:05:08.000 +07:00 conflict
test.user@example.com 2001-02-03 04:05:08.000 +07:00 813918f7b4e6 conflict
my description
8f02f5470c55 test.user@example.com 2001-02-03 04:05:08.000 +07:00
test.user@example.com 2001-02-03 04:05:08.000 +07:00 8f02f5470c55
my description
c8ceb219336b test.user@example.com 2001-02-03 04:05:08.000 +07:00
test.user@example.com 2001-02-03 04:05:08.000 +07:00 c8ceb219336b
my description
"###);
// Test `--git` format, and that it implies `-p`
let stdout = get_log_output(&test_env, &repo_path, &["obslog", "--no-graph", "--git"]);
insta::assert_snapshot!(stdout, @r###"
1daafc17fefb test.user@example.com 2001-02-03 04:05:08.000 +07:00
test.user@example.com 2001-02-03 04:05:08.000 +07:00 1daafc17fefb
my description
diff --git a/file1 b/file1
index e155302a24...2ab19ae607 100644
@ -96,9 +96,9 @@ fn test_obslog_with_or_without_diff() {
-+bar
->>>>>>>
+resolved
813918f7b4e6 test.user@example.com 2001-02-03 04:05:08.000 +07:00 conflict
test.user@example.com 2001-02-03 04:05:08.000 +07:00 813918f7b4e6 conflict
my description
8f02f5470c55 test.user@example.com 2001-02-03 04:05:08.000 +07:00
test.user@example.com 2001-02-03 04:05:08.000 +07:00 8f02f5470c55
my description
diff --git a/file1 b/file1
index 257cc5642c...3bd1f0e297 100644
@ -114,7 +114,7 @@ fn test_obslog_with_or_without_diff() {
+++ b/file2
@@ -1,0 +1,1 @@
+foo
c8ceb219336b test.user@example.com 2001-02-03 04:05:08.000 +07:00
test.user@example.com 2001-02-03 04:05:08.000 +07:00 c8ceb219336b
my description
"###);
}
@ -136,36 +136,36 @@ fn test_obslog_squash() {
let stdout = get_log_output(&test_env, &repo_path, &["obslog", "-p", "-r", "@-"]);
insta::assert_snapshot!(stdout, @r###"
o 9b6d4a272a6a test.user@example.com 2001-02-03 04:05:07.000 +07:00
o test.user@example.com 2001-02-03 04:05:07.000 +07:00 9b6d4a272a6a
|\ squashed
| | Modified regular file file1:
| | 1 1: foo
| | 2: bar
o | 803a7299cb1a test.user@example.com 2001-02-03 04:05:07.000 +07:00
o | test.user@example.com 2001-02-03 04:05:07.000 +07:00 803a7299cb1a
| | first
| | Added regular file file1:
| | 1: foo
o | 85a1e2839620 test.user@example.com 2001-02-03 04:05:07.000 +07:00
o | test.user@example.com 2001-02-03 04:05:07.000 +07:00 85a1e2839620
| | first
o | 230dd059e1b0 test.user@example.com 2001-02-03 04:05:07.000 +07:00
o | test.user@example.com 2001-02-03 04:05:07.000 +07:00 230dd059e1b0
/ (no description set)
o 69231a40d60d test.user@example.com 2001-02-03 04:05:09.000 +07:00
o test.user@example.com 2001-02-03 04:05:09.000 +07:00 69231a40d60d
| second
| Modified regular file file1:
| 1 1: foo
| 2: bar
o b567edda97ab test.user@example.com 2001-02-03 04:05:09.000 +07:00
o test.user@example.com 2001-02-03 04:05:09.000 +07:00 b567edda97ab
second
"###);
}
fn get_log_output(test_env: &TestEnvironment, repo_path: &Path, args: &[&str]) -> String {
// Filter out the change ID since it's random
let regex = Regex::new("^([o@| ]+)?([0-9a-f]{12}) ([0-9a-f]{12}) ").unwrap();
let regex = Regex::new("^([o@| ]+)?([0-9a-f]{12})").unwrap();
let mut lines = vec![];
let stdout = test_env.jj_cmd_success(repo_path, args);
for line in stdout.split_inclusive('\n') {
lines.push(regex.replace(line, "$1$2 "));
lines.push(regex.replace(line, "$1"));
}
lines.join("")
}