Commit graph

120 commits

Author SHA1 Message Date
David Higgs
223470295e cli: remove newline addition between template and content
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-24.04) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
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.
2025-12-22 02:47:58 +00:00
Scott Taylor
33ad38bfed templates: add "divergent" label to log for divergent changes
It would be good to include the word "divergent" in the log when a
change is divergent, since users are often unsure what's happening when
they see a divergent change, and giving them a term to search for would
be helpful. However, I don't think it looks good to put this label next
to the change ID itself if both are the same color, since it ends up
being hard to distinguish from the change offset at a glance. Also,
putting the label next to the change ID also messes up the alignment of
fields in the log. Therefore, I think it looks better to put the
"divergent" label at the end of the line.

Since divergence and hidden commits are similar, it makes sense for both
labels to be in the same place, so I also moved the hidden label to the
end for consistency.

One downside is that the labels are less obviously connected with the
change ID itself due to them being farther apart. I think this could be
fine, since they are still visually connected by being the same color.
2025-12-20 16:55:51 +00:00
Scott Taylor
04a91217f5 rewrite: add conflict labels when merging commit trees
An example with parents `rtsqusxu` and `ysrnknol`:

```
<<<<<<< conflict 1 of 1
%%%%%%% diff from: vpxusssl 38d49363 "description of base"
\\\\\\\        to: rtsqusxu 2768b0b9 "description of left"
-base
+left
+++++++ ysrnknol 7a20f389 "description of right"
right
>>>>>>> conflict 1 of 1 ends
```
2025-12-20 04:03:57 +00:00
Scott Taylor
ba73442b2a conflicts: update conflict marker format
Conflict labels will generally start with lowercase change IDs, so
making all of the text lowercase makes it more consistent. I also
removed the "contents of" text, since conflict labels will already be
long enough, and this text doesn't add anything. Similarly, I removed
the "(conflict 1 of 1)" note from the Git conflict markers since Git
doesn't include this information, and including it would result in extra
long lines once we add conflict labels.
2025-12-20 04:03:57 +00:00
Yuya Nishihara
97375fa041 revset: enable glob string matching by default
Follows up c93682f2 "revset: parameterize default string pattern kind, add
config knob".
2025-12-15 04:27:32 +00:00
Yuya Nishihara
2f9041b842 diff: reduce intensity of context line numbers in color-words diffs
This will help notice small hunks in inlined diff lines. Not all terminals would
support "dim" attribute, but I think that's okay since the diff output should be
readable with/without this change.

Closes #5140
2025-12-13 00:56:55 +00:00
Yuya Nishihara
c6cc177103 config: remove outdated migration rules 2025-12-11 00:49:58 +00:00
David Higgs
ee650cb6a2 tests: exercise reverse order diff and --to 2025-12-06 13:11:12 +00:00
Steve Klabnik
5b3aa51140 docs: jj-vcs.github.io -> jj-vcs.dev
As a follow-up to #8115, this moves all references in the codebase to use the new website.

I didn't update the older CHANGELOG entries because I figured they're intended
to be immutable.
2025-11-26 00:36:39 +00:00
Yuya Nishihara
3b37ed102e tests: specify string pattern prefix, use subject(glob:_) accordingly
Deprecation warnings will be emitted for default "substring:" patterns. This
change will suppress them. Since "glob:" will be the new default, I made these
tests use "glob:" when both "exact:" and "glob:" work.

Tests for the revset filter functions aren't updated.
2025-11-24 01:39:32 +00:00
Yuya Nishihara
84c7f5d562 cli: diff: pass $width parameter to external diff tools
Closes #4161
2025-09-16 01:49:21 +00:00
Evan Martin
60a6e9421b cli: make diff --stat show byte counts for binary files
Fixes #6865.
2025-08-09 21:36:04 +00:00
Austin Seipp
ba24140f1d cli, lib: move to Rust 2024 language edition
This applies a `cargo fmt` and fixes clippy lints to keep the build
properly working.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
2025-07-28 17:05:41 +00:00
Martin von Zweigbergk
a054ca9c92 diff: disallow diff of range with incoming merge edges
We could allow merge edges coming into the range of commits but it's
probably a rare use case and it's a bit complicated to implement while
also preserving the parent order. Simply disallowing such cases for
now is better than producing incorrect results.
2025-07-26 18:32:20 +00:00
Martin von Zweigbergk
3423543094 cli: demonstrate bug in jj diff -r with merge into chain 2025-07-26 18:32:20 +00:00
Bryce Berger
38a23f9b24 diff stat: ensure bar always has 2 spaces for commits with adds and removes
closes #7026
2025-07-20 08:22:25 +00:00
Bryce Berger
2c84812748 diff tests: demonstrate bug in --stat with narrow terminal, adds, and removes 2025-07-20 08:22:25 +00:00
Ilya Grigoriev
fedbc3017f cli merge tools: allow setting diff-args=[] to disable diff formatting with a tool
Not setting `diff-args` is equivalent to `diff-args=["$left",
"$right"]`, which I also documented here.

I couldn't decide whether the new error should be part of
`DiffRenderError`, `DiffGenerateError`, or `MergeToolError`. Since the
treatment of diff formatters is already very different from other merge
tools, I just made it a CommandError for now.
2025-07-19 03:39:16 +00:00
Evan Martin
d9b0a42a85 cli: make diff --stat fill available width
Previously, the computation for the available display width
included a padding constant, but this value was then used as
an upper bound for the width of the bar.  This meant the bar
would never fill the available screen width.
2025-07-17 02:03:16 +00:00
Evan Martin
228ea38aeb tests: make diff --stat test filenames clearer
Change the file names in the test to reflect a bit about what they're testing,
and add a test for a file that is a binary->binary modification.
2025-07-17 02:03:16 +00:00
Yuya Nishihara
26ba2a0975 cli: add "diff --template" argument
Since the commit template now supports diff.files(), it would probably make
sense that the diff command has the same functionality.

Closes #6681
2025-06-15 15:09:08 +00:00
Martin von Zweigbergk
98d884827e cli: for deprecated configs, say at which source level they were found
I had a report from a user at Google who was confused about a config
deprecation message because they had forgotten that they set a
repo-level config. This patch includes the source level in the warning
message. Hopefully that's sufficient. We could of course print the
path too, but that would make the message much longer so we would have
to split it up on two lines and I'm not sure it's worth it.
2025-05-28 20:01:51 +00:00
Yuya Nishihara
88d79c135b cli: accept --tool=:<format> argument as builtin diff format
This is just for completeness. I don't think this is practically useful, but the
:<format> syntax should work in both config files and command arguments.
2025-05-17 00:11:00 +00:00
Yuya Nishihara
851d25cd68 cli: unify diff format/tool config variables
This allows users to override the external tool set in ~/.jjconfig.toml. The
config variable is renamed to ui.diff-formatter to be consistent with the other
diff/merge editor settings.

--tool=:<format> support will be added separately.

Closes #3327
2025-05-16 00:33:49 +00:00
Eyvind Bernhardsen
94f28e95b5 diff: Run external diff tools in their temp dir
The name of the temporary directory that is created when running
external diff tools can add significant noise to a diff if the tool
displays paths prominently.

Change the behaviour so that we chdir to the temporary directory before
running the tool, with a setting to revert to the previous behaviour.

Closes #5801
2025-05-12 21:34:19 +00:00
Yuya Nishihara
79fb219159 files: make DiffLineIterator omit blank right line following matching+left
I was wondering whether this is presentation issue or not, and I think it is a
matter of DiffLineIterator. For matching hunks, DiffLineIterator flushes the
current_line buffer and bumps the line numbers for the next line. This should
guarantee that there are no blank DiffLine to be queued. However, for different
hunks, only the left line number can be bumped in the first loop, so there may
be an empty-looking hunk having the same right line number.

Closes #6471
2025-05-09 00:49:10 +00:00
Yuya Nishihara
39295238ac tests: demonstrate redundant right blank lines in color-words diffs 2025-05-09 00:49:10 +00:00
Martin von Zweigbergk
acd824269f git: write change-id header by default
We haven't had any reports of problems from people who opted in. Since
it's early in the release cycle now, let's now test it on everyone who
builds from head, so we get almost a month of testing from those
people before it's enabled by default in a released version.

This impacts lots of test cases because the change-id header is added
to the Git commit. Most are uninteresting. `test_git_fetch` now sees
some divergent changes where it used to see only divergent bookmarks,
which makes sense.
2025-05-08 23:05:38 +00:00
Yuya Nishihara
0e17c0e17d copies: ignore existing tree when testing copy/rename operation type
In this context, a tree value should be considered absent.
2025-04-22 00:44:13 +00:00
Yuya Nishihara
b6a861b529 git_backend: do not include renamed trees in copy records
We could instead make CopiesTreeDiffStream reject bad copy records, but it's
pretty much wrong to construct a FileId for tree.

Fixes #6390
2025-04-22 00:44:13 +00:00
Yuya Nishihara
b63ab33b10 diff: add option to render color-words diffs without materializing conflicts
The original idea was to flatten left/right conflict trees and pair up adjacent
negative/positive terms. For example, diff(A, B-C+D) could be rendered as
diff(A, B) and diff(C, D). The problem of this formalization is that one of the
diff pairs is often empty (because e.g. A=B), so the context is fully omitted.
The resulting diff(C, D) doesn't provide any notion why the hunk is conflicted,
and how it is different from A.

Instead, this patch implements diffs in which each left/right pair is compared.
In the example above, the left terms are padded, and the diffs are rendered as
diff(A, B), diff(-A, -C), diff(A, D). This appears to be working reasonably well
so long as either side is resolved or both sides have the same numbers of terms.

Closes #4062
2025-04-08 09:12:39 +00:00
Yuya Nishihara
8af238f68a diff: test identical contents early when rendering color-words diffs
This helps extract hunk rendering function for non-materialized color-words
diffs. In conflict hunk, an identical diff pair will be omitted with "..."
marker.

This patch introduces a subtle behavior change when "ignore whitespace" options
are used. Before, "..."  wouldn't be printed if contents differ only in
whitespace. I don't think the new behavior is bad because the file header says
"Modified regular file" in that case.
2025-04-08 09:12:39 +00:00
Yuya Nishihara
4ae00a6cb4 tests: add samples of conflict diff rendering 2025-04-08 09:12:39 +00:00
Yuya Nishihara
b000c94a7a tests: add work_dir.dir(path), make create_dir*() return helper for sub dir
I found this pattern is common.
2025-03-18 01:25:08 +00:00
Ilya Grigoriev
acaedc3382 cleanup: enable unused_trait_names clippy lint and run clippy --fix 2025-03-16 00:35:56 +00:00
Yuya Nishihara
31620a11ae tests: port test_diff_command.rs to TestWorkDir API 2025-03-15 02:41:22 +00:00
Yuya Nishihara
fc84c639f7 tests: configure fake editor early in test_diff*_command.rs
This works around borrowing issue of test_env.
2025-03-15 02:41:22 +00:00
Martin von Zweigbergk
dc7216d73a cli: diff: support multiple revisions to -r 2025-03-11 06:27:51 +00:00
Ilya Grigoriev
5eae2d92a0 tests: run insta --force-update-snapshots
This is a replacement for #5558.

Thanks to @yuja 's https://github.com/mitsuhiko/insta/pull/722, this is
now easy to generate.
2025-03-06 21:35:08 +00:00
Yuya Nishihara
7fa8420908 tests: resolve directory path to run_jj_in() relative to env_root
Suppose we'll add test_env.init_workspace(path) or something, this will probably
make sense.
2025-02-25 15:40:14 +00:00
Yuya Nishihara
ad6985fd9c tests: migrate unusual patterns of jj_cmd_ok() to run_jj_in()
These callers are manually ported to run_jj_in().
2025-02-24 15:39:11 +00:00
Yuya Nishihara
804d175fd9 tests: migrate non-snapshot users of jj_cmd_ok() to run_jj_in().success()
These callers were mostly substituted mechanically.
2025-02-24 15:39:11 +00:00
Yuya Nishihara
3193513049 tests: migrate snapshot users of jj_cmd_ok() to run_jj_in()
These callers were mostly substituted mechanically, then fixed up formatting.
2025-02-24 15:39:11 +00:00
Yuya Nishihara
cdcc777730 tests: migrate snapshot users of jj_cmd_success() to run_jj_in()
These callers were mostly substituted mechanically, then fixed up minor
formatting and name errors.
2025-02-23 13:34:17 +00:00
Yuya Nishihara
317993894b tests: migrate unusual users of jj_cmd_success() to run_jj_in/with()
These callers are manually ported to run_jj_in(). assert_eq!() is changed to
insta::assert_snapshot!() where possible.
2025-02-23 13:34:17 +00:00
Yuya Nishihara
a326b6e792 tests: migrate jj_cmd_success() output wrappers to run_jj_in() 2025-02-23 13:34:17 +00:00
Yuya Nishihara
b79b29c288 tests: migrate callers of jj_cmd_cli_error() to run_jj_in() 2025-02-23 03:06:59 +00:00
Yuya Nishihara
f1cd3a4e53 tests: migrate some jj_cmd_success() output wrappers to run_jj_in() 2025-02-22 01:23:04 +00:00
Yuya Nishihara
e23290d95d tests: migrate users of strip_last_line() to run_jj_in() function 2025-02-21 01:49:41 +00:00
Yuya Nishihara
cf7f1dfc88 tests: migrate users of normalize_exit_status() to run_jj_in() function 2025-02-21 01:49:41 +00:00