mirror of
https://github.com/jj-vcs/jj.git
synced 2025-12-23 06:01:01 +00:00
cli: remove newline addition between template and content
Commands `jj log`, `jj evolog`, and `jj op log` automatically added a terminating newline when the expanded template did not include one in graph mode. No-graph mode did not do this, so the expanded template could combine with any following content (diff, op changes, etc) in confusing or problematic ways. Instead of trying to compensate in all cases, remove the auto-fixups. Users should confirm their custom templates still expand correctly for their needs.
This commit is contained in:
parent
d8e51087a2
commit
223470295e
9 changed files with 12 additions and 28 deletions
|
|
@ -38,6 +38,9 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|||
|
||||
* The deprecated `commit_id.normal_hex()` template method has been removed.
|
||||
|
||||
* Template expansion that did not produce a terminating newline will not be
|
||||
fixed up to provide one by `jj log`, `jj evolog`, or `jj op log`.
|
||||
|
||||
### Deprecations
|
||||
|
||||
* The `git_head()` and `git_refs()` functions will be removed from revsets and
|
||||
|
|
|
|||
|
|
@ -174,9 +174,6 @@ pub(crate) fn cmd_evolog(
|
|||
within_graph.write(ui.new_formatter(&mut buffer).as_mut(), |formatter| {
|
||||
template.format(&entry, formatter)
|
||||
})?;
|
||||
if !buffer.ends_with(b"\n") {
|
||||
buffer.push(b'\n');
|
||||
}
|
||||
if let Some(renderer) = &diff_renderer {
|
||||
let predecessors: Vec<_> = entry.predecessors().try_collect()?;
|
||||
let mut formatter = ui.new_formatter(&mut buffer);
|
||||
|
|
|
|||
|
|
@ -273,9 +273,6 @@ pub(crate) fn cmd_log(
|
|||
within_graph.write(ui.new_formatter(&mut buffer).as_mut(), |formatter| {
|
||||
template.format(&commit, formatter)
|
||||
})?;
|
||||
if !buffer.ends_with(b"\n") {
|
||||
buffer.push(b'\n');
|
||||
}
|
||||
if let Some(renderer) = &diff_renderer {
|
||||
let mut formatter = ui.new_formatter(&mut buffer);
|
||||
renderer
|
||||
|
|
|
|||
|
|
@ -208,9 +208,6 @@ pub fn show_op_diff(
|
|||
modified_change,
|
||||
)
|
||||
})?;
|
||||
if !buffer.ends_with(b"\n") {
|
||||
buffer.push(b'\n');
|
||||
}
|
||||
if let Some(diff_renderer) = diff_renderer {
|
||||
let mut formatter = ui.new_formatter(&mut buffer);
|
||||
show_change_diff(
|
||||
|
|
@ -346,7 +343,6 @@ pub fn show_op_diff(
|
|||
)
|
||||
})?;
|
||||
}
|
||||
writeln!(formatter)?;
|
||||
}
|
||||
|
||||
let ignored_remote = default_ignored_remote_name(current_repo.store());
|
||||
|
|
|
|||
|
|
@ -223,9 +223,6 @@ fn do_op_log(
|
|||
within_graph.write(ui.new_formatter(&mut buffer).as_mut(), |formatter| {
|
||||
template.format(&op, formatter)
|
||||
})?;
|
||||
if !buffer.ends_with(b"\n") {
|
||||
buffer.push(b'\n');
|
||||
}
|
||||
if let Some(show) = &maybe_show_op_diff {
|
||||
let mut formatter = ui.new_formatter(&mut buffer);
|
||||
show(ui, formatter.as_mut(), &op, &within_graph)?;
|
||||
|
|
|
|||
|
|
@ -3319,13 +3319,11 @@ fn test_diff_external_available_width() {
|
|||
cmd.args(["log", "--tool=echo", "-T''"])
|
||||
.env("COLUMNS", "50")
|
||||
});
|
||||
insta::assert_snapshot!(output, @r"
|
||||
@
|
||||
│ 47
|
||||
│ ○
|
||||
├─╯ 45
|
||||
◆
|
||||
47
|
||||
insta::assert_snapshot!(output, @"
|
||||
@ 47
|
||||
│ ○ 45
|
||||
├─╯
|
||||
◆ 47
|
||||
[EOF]
|
||||
");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -237,14 +237,13 @@ fn test_log_with_or_without_diff() {
|
|||
│ 1 file changed, 1 insertion(+), 0 deletions(-)
|
||||
│ Added regular file file1:
|
||||
│ 1: foo
|
||||
◆
|
||||
0 files changed, 0 insertions(+), 0 deletions(-)
|
||||
◆ 0 files changed, 0 insertions(+), 0 deletions(-)
|
||||
[EOF]
|
||||
");
|
||||
|
||||
// `--stat` is short format, which should be printed first
|
||||
let output = work_dir.run_jj(["log", "-T", "description", "--git", "--stat"]);
|
||||
insta::assert_snapshot!(output, @r"
|
||||
insta::assert_snapshot!(output, @"
|
||||
@ a new commit
|
||||
│ file1 | 1 +
|
||||
│ 1 file changed, 1 insertion(+), 0 deletions(-)
|
||||
|
|
@ -265,8 +264,7 @@ fn test_log_with_or_without_diff() {
|
|||
│ +++ b/file1
|
||||
│ @@ -0,0 +1,1 @@
|
||||
│ +foo
|
||||
◆
|
||||
0 files changed, 0 insertions(+), 0 deletions(-)
|
||||
◆ 0 files changed, 0 insertions(+), 0 deletions(-)
|
||||
[EOF]
|
||||
");
|
||||
|
||||
|
|
|
|||
|
|
@ -601,7 +601,6 @@ fn test_op_log_word_wrap() {
|
|||
insta::assert_snapshot!(
|
||||
render(&["op", "log", "-T''", "--op-diff", "-n1", "--config", config], 15, true), @r"
|
||||
@
|
||||
│
|
||||
│ Changed
|
||||
│ commits:
|
||||
│ ○ + 0 1 2 3
|
||||
|
|
|
|||
|
|
@ -2111,8 +2111,7 @@ fn test_squash_to_new_commit() {
|
|||
│ A file2
|
||||
○ qpvuntsmwlqt bm1 file1
|
||||
│ A file1
|
||||
○ soqnvnyzoxuu
|
||||
│ A file3
|
||||
○ soqnvnyzoxuuA file3
|
||||
│ A file4
|
||||
◆ zzzzzzzzzzzz
|
||||
[EOF]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue