Commit graph

4385 commits

Author SHA1 Message Date
Scott Taylor
8c84656c36 git_backend: clean up root tree parsing logic
Some checks failed
Scorecards supply-chain security / Scorecards analysis (push) Has been cancelled
binaries / Build binary artifacts (push) Has been cancelled
website / prerelease-docs-build-deploy (ubuntu-24.04) (push) Has been cancelled
This makes `extract_root_tree_from_commit()` match
`extract_change_id_from_commit()`.
2025-12-06 21:20:17 +00:00
Martin von Zweigbergk
a95d9084e4 matchers: move RepoPathTree to repo_path module
I plan to use this type in at least `TreeBuilder`.

I renamed some `dir` variables to `path` since I don't think they have
to be directories.
2025-12-06 16:27:21 +00:00
Martin von Zweigbergk
c8a352424f matchers: don't access RepoPathTree fields directly
I plan to move the type to another module. This patch updates the
callers in `matchers` to use what will become the public API.
2025-12-06 16:27:21 +00:00
xtqqczze
c49a60e5eb clippy: enable unnecessary_literal_bound lint
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
2025-12-05 17:07:44 +00:00
Martin von Zweigbergk
94d2c04a75 cleanup: address two Clippy unnecessary_unwrap warnings
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
2025-12-05 09:22:10 +00:00
Kaiyi Li
eb1f72a0c9 file_util: fix broken symlink on Windows
... due to using incorrect separators.

Fix #8185.
2025-12-05 03:43:34 +00:00
xtqqczze
9f8eb428aa clippy: fix explicit_into_iter_loop lint 2025-12-05 01:43:58 +00:00
xtqqczze
b0ee9bdd09 clippy: fix cast_lossless lint
https://rust-lang.github.io/rust-clippy/master/index.html#cast_lossless
2025-12-05 01:42:41 +00:00
xtqqczze
a3074efaac cleanup: correct backtick usage in documentation comments
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
2025-12-04 21:42:30 +00:00
Ian Wrzesinski
bcfd5c977c config: Add "exec-bit-change" setting for overriding policy on Unix 2025-12-04 17:32:40 +00:00
Ian Wrzesinski
aaf20d9e1f working_copy: Add executable bit change policy 2025-12-04 17:32:40 +00:00
Ian Wrzesinski
8dda6b6996 working_copy: Clean up ExecBit interface and preserve on-disk exec state on Windows 2025-12-04 17:32:40 +00:00
Ian Wrzesinski
bea5882e13 working_copy: Rename FileExecutableFlag to ExecBit and update variables
The main reason for this change is that we now give variables different names
based on their types. This helps avoid confusion and makes intent clearer.
However, the type name `FileExecutableFlag` doesn't have a good shortening
(`file_exec_flag` is annoyingly long), so I also renamed the type to something
shorter, which makes the code more legible: easier to mentally parse and
quicker to type.

I removed `File` from the name both for length and because it doesn't really
help distinguish from the executable field in `TreeValue` (because that field
is nested under `TreeValue::File`). Instead, in the upcoming commits I update
comments to consistently use the terms 'on-disk' and 'in-repo' to respectively
refer to the fields in the `FileState` and `TreeValue` structs, which I find
is better for keeping the difference clear in my head.

I went with `Bit` in the new name just because I'm already changing it and I
prefer `exec_bit` slightly over `exec_flag` as the variable name.
2025-12-04 17:32:40 +00:00
Ian Wrzesinski
b8cfd972ed lib/tests: Add basic executable bit tests on Unix 2025-12-04 17:32:40 +00:00
Martin von Zweigbergk
4c8eac125e lib: derive Debug on a few more types
I wanted to do print a `TreeDiffEntry` and noticed that it didn't
implement `Debug`. This patch adds it for that type and for some
others I found.
2025-12-04 01:02:53 +00:00
Yuya Nishihara
36143b093e git: add native support for negative fetch patterns
The default patterns are still saved to and loaded from .git/config. Maybe we
can add default fetch patterns to jj's configuration, but I'm not sure whether
we should deprecate .git/config fallback.
2025-12-03 08:12:58 +00:00
Yuya Nishihara
d9be0dbfeb git: add function to extract positive/negative refspecs from StringExpression
This allows us to express negative refspecs in jj's syntax. We'll need something
like `git.fetch-tags = <patterns>` to fetch tags into remote views and merge
them accordingly #7528. The default tag patterns can't be set to .git/config
because Git processes remote tags differently.
2025-12-03 08:12:58 +00:00
Yuya Nishihara
8615362689 git: compile both positive/negative branch patterns to StringMatcher
I also renamed "branch" to "bookmark" because we call refs as "bookmark"s where
the matcher is used.
2025-12-03 07:32:25 +00:00
Yuya Nishihara
1d897341cc git: parse negative refspecs to branch patterns
We'll need negative patterns to exclude them when importing remote refs from Git
repository.
2025-12-03 07:32:25 +00:00
Yuya Nishihara
06bc9ef05d git: do refspec.to_ref() by expand_default_fetch_refspecs()
We can get allow_non_fast_forward from the instruction enum instead.
2025-12-03 07:32:25 +00:00
Yuya Nishihara
99f4774455 git: pass typed remote name from expand_default_fetch_refspecs() 2025-12-03 07:32:25 +00:00
Yuya Nishihara
bc7c1abb05 git: extract parsing function from expand_default_fetch_refspecs()
The control flow can be simplified by wrapping in -> Result function.
2025-12-03 07:32:25 +00:00
Matt Stark
668a034e08 working-copy: Ensure sub-repos are not tracked.
If a submodule was created in a commit C on a remote repo, switching from any
commit after C to any commit before C (eg. `jj new C-`) will result in jj
starting to track the files introduced in the submodule.

This issue has popped up very frequently for chromium developers, who
get issues when attempting to check out an older version of chromium.

Fixes #4349
2025-12-02 23:20:34 +00:00
Martin von Zweigbergk
d4f0859a9e working_copy: determine staleness by comparing op id instead of tree id
Our detection of stale working copy is based on the tree id since a
long time ago, at least since Feb 2022 (e098c01935) depending on how
you count. Since Sep 2022 (443e73f346), we keep the last operation
recorded in the working copy up to date. However, we don't update it
when the tree id matches. That's inconsistent, so I think we should
always keep it up to date. This patch fixes that.

Thanks to @kevincliao for spotting this. We noticed this at Google
because it meant that we sometimes didn't notice the new operation id
in our distributed file system, which led to the machine creating
divergent operations.  (The machine is supposed to detect operations
recorded in the operation log but this is sometimes flaky for
unrelated reasons.)
2025-12-02 16:48:10 +00:00
Yuya Nishihara
dd41f0ea08 conflicts: wrap materialized diff values in Diff<T>
Since the original values are of Diff<MergedTreeValue> type, the materialized
version should also be Diff<T>.
2025-12-02 14:52:28 +00:00
Matt Stark
25cf636e19 revsets: Update message to clarify that the default is usually exact. 2025-12-01 23:19:59 +00:00
Mitchell Skaggs
2af8bf94a3 testutils: add check for strict UTF-8 filesystems
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
`test_init_load_non_utf8_path` and
`test_init_additional_workspace_non_utf8_path` now early-return on
strict UTF-8 filesystems because there's no way to report a test as
"skipped" at runtime.

Closes https://github.com/jj-vcs/jj/issues/8118
2025-11-27 00:36:39 +00:00
Yuya Nishihara
d444f0578a cli: show warnings for unmatched exact bookmark/tag patterns to list
The idea is the same as filesets. We emit warnings for exact names that don't
exist in the search space.
2025-11-26 14:46:17 +00:00
Yuya Nishihara
b78ec81023 str_util: add StringExpression::exact_strings() iterator
The implementation is copied from FilesetExpression.
2025-11-26 14:46:17 +00:00
Lander Brandt
7e42895b59 lib: substantially reduce syscalls when attempting to create dirs
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
After filing https://github.com/jj-vcs/jj/issues/7685 I ran some perf traces to try to understand just what was taking so long during these slow operations. The changes in this PR reduces clone time for my large repo from about 10 minutes to 4m30s.

You can see my thought process in the comments of the above task but to summarize:

During checkout we check files/directories being created to ensure that we are not attempting to write to a reserved directory (`.jj/`, `.git/`). `same_file::is_same_file()` is an expensive check that invokes _at least 4_ syscalls when called in a naive manner (`open()` and `close()` for each path -- plus possibly more for getting file info? I haven't counted).

There are a few optimization gaps here that are causing significant slowdowns. The following checklist reflects what I've optimized in this PR, and what still remains:

- [x] `create_parent_dirs` will be called for each file/directory and for each parent dir in a path **try to create it and check if the dir is an illegal name via `reject_reserved_existing_path()`**. There is no caching of directories which have already been created.
- [ ] `reject_reserved_existing` calls `same_file::is_same_file()` in a loop for all reserved names, but the path which _has maybe been created_ isn't going to change, so its handle could be cached.
- [ ] `can_create_new_file` attempts to create the file then just uses the result as an indicator of whether or not the file is created. However, since we _have a `File`_ that `File` can be directly converted to a `same_file::Handle` and avoid a syscall that currently occurs when converting the `Path` to a `same_file::Handle`.
- [ ] `can_create_new_file` deletes the file immediately after. There's probably an opportunity here to **not** delete the file and re-use it for file write operations.
- [ ] Say we have 1000 files in `foo/`. For each file that's written, `reject_reserved_existing` is going to make at least `RESERVED_DIR_NAMES.len() * 1000` syscalls constructing `foo/{reserved_dir_name}` paths, testing their existence, etc. Maybe `jj` might create this dir? But I don't think that should ever happen -- so why not cache the handle **if** it's created and use a lookup table in `reject_reserved_existing` to only conduct these types of checks if the handle is resolved? Or alternatively cache that the file _does not_ exist after the first check.

Here are some perf traces of running a `jj git clone` of my large repo before:

Release: https://share.firefox.dev/4oiSTBw
Debug: https://share.firefox.dev/4qmJBX1

And after:

Release: https://share.firefox.dev/4nK66mH
Debug: https://share.firefox.dev/470W1ed
2025-11-26 02:30:31 +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
c93682f218 revset: parameterize default string pattern kind, add config knob
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
Glob patterns will be enabled by default globally. Since this will be a big
breaking change in revsets, this patch adds a config knob to turn the new
default on/off.
2025-11-24 01:39:32 +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
4d296a7f9f str_util: map glob pattern with no meta character to exact pattern
Suppose the default is changed to "glob:", literal strings would be parsed by
glob() function. It's still better to treat trivial strings as "exact" patterns.

str_util::is_glob_char() includes backslash unconditionally because we enable
backslash escapes in string patterns.
2025-11-24 01:39:32 +00:00
Yuya Nishihara
afd44830e4 revset: add string expression parser for command arguments
The default patterns differ between revsets and command arguments, but they'll
be unified to "glob" later. For now, parse_string_expression() should be used
only for command arguments.
2025-11-23 03:00:12 +00:00
Yuya Nishihara
69c36fe1b9 revset: restore parsing rule for expression without "modifier:" syntax
The new parse_program() will allow us to parse top-level string patterns with no
parentheses. This patch also replaces a few callers of the old parse_program().
When we drop support for the all: modifier syntax, parse_program_with_modifier()
will be replaced entirely.
2025-11-23 03:00:12 +00:00
Yuya Nishihara
a7a4ed033a git: move GitSettings out of settings module
This type wouldn't be needed if the "git" feature is disabled.
2025-11-21 15:04:09 +00:00
Yuya Nishihara
0361059f65 git: move git.colocate to CLI config
This is the option for "jj git" subcommands.
2025-11-21 15:04:09 +00:00
Remo Senekowitsch
5ada0f7ff2 config: deprecate git.auto-local-bookmark
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
2025-11-21 05:15:55 +00:00
Remo Senekowitsch
e4d45dda34 tests: replace auto-local-bookmark with auto-track-bookmarks
This paves the way to deprecate `git.auto-local-bookmark` without
adding lots of deprecation warnings to test output snapshots.

The behavior of some tests is slightly changed, because
auto-track-bookmarks also tracks bookmarks that were created locally.
I think it just shows up in output snapshots as absent-tracked
bookmarks, without affecting what the test is about.
2025-11-21 05:15:55 +00:00
Remo Senekowitsch
4216aa6758 config: add remotes.<name>.auto-track-bookmarks
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
This configuration allows users to express a set of bookmarks that
should be automatically tracked when first encountered. This includes
on clone, fetch, create and set.

Until now, the configuration values `git.push-new-bookmarks` and
`git.auto-local-bookmark` fulfilled parts of those use cases. However,
both options represent an "all or nothing" approach. By turning them on,
users risk tracking and pushing more bookmarks than desired.

By using a bookmark pattern, users can express that they want to
auto-track bookmarks that belong to them (e.g. `glob:my-name/*`).
2025-11-18 15:10:56 +00:00
Yuya Nishihara
39cd3e00d1 ssh_signing: don't require ownership unnecessarily when parsing output
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
2025-11-17 14:17:32 +00:00
Yuya Nishihara
8091682c0b revset: allow unquoted * in identifier (or pattern expression)
Some checks failed
binaries / Build binary artifacts (push) Has been cancelled
website / prerelease-docs-build-deploy (ubuntu-24.04) (push) Has been cancelled
Scorecards supply-chain security / Scorecards analysis (push) Has been cancelled
I'm going to fix parsing of CLI string patterns to use revset parser, and it
would be annoying if inner quotes were required in addition to shell quotes:

  $ jj bookmark list 'glob:"push-*"'

There's also a plan to enable glob matching globally. This will mean that we'll
have to use either `subject(*foo*)` or `subject(substring:foo)` for substring
search.

https://github.com/jj-vcs/jj/issues/6971#issuecomment-3067038313
2025-11-15 04:11:57 +00:00
Lucio Franco
d9f2772988 cli: add jj file track --include-ignored flag
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
This adds support for tracking ignored and oversized files with `jj file track`.

Previously, `jj file track` would silently fail to track files that were ignored by
`.gitignore` or larger than `snapshot.max-new-file-size`. This commit introduces an
`--include-ignored` flag that allows users to explicitly track these files.

## Implementation

Added a `force_tracking_matcher` field to `SnapshotOptions` that overrides ignore rules
and size limits. When `--include-ignored` is specified, the file pattern matcher is
passed as `force_tracking_matcher`, allowing three checks in `FileSnapshotter` to bypass
their usual restrictions for directory ignores, file ignores, and file size limits.

## Tests

- `test_track_ignored_with_flag`: Verifies `.gitignore`d files can be tracked
- `test_track_large_file_with_flag`: Verifies oversized files can be tracked
- `test_track_ignored_directory`: Verifies ignored directories can be tracked recursively

# Checklist

If applicable:

- [ ] I have updated `CHANGELOG.md`
- [x] I have updated the documentation (`README.md`, `docs/`, `demos/`)
- [ ] I have updated the config schema (`cli/src/config-schema.json`)
- [x] I have added/updated tests to cover my changes
2025-11-14 03:14:37 +00:00
Joseph Lou
9014f64f69 template: Fail on unexpected keyword arguments
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
Any keyword arguments given to the `coalesce()` and `concat()` functions
were being silently ignored because `FunctionCallNode.args` was being
accessed directly without checking `keyword_args` at all.
2025-11-13 05:15:40 +00:00
Yuya Nishihara
ca797e087c fileset: enable glob matching by default
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
Since file names don't usually include glob meta characters, it's probably okay
to enable globs by default. There's also a plan to change the default of string
patterns to globs.

The short forms "cwd:"/"root:" are still aliased to literal patterns. I don't
have a strong reason to rename these.

Closes #6971
2025-11-12 11:27:41 +00:00
Yuya Nishihara
d06ab5abb9 fileset: add prefix glob patterns
"prefix-glob:" will be the default. I don't think these prefix glob patterns
are useful, but they are added for completeness.

It's odd that literal patterns do prefix matching by default whereas globs match
exactly. We can instead rename the existing "glob:" to "file-glob:" and add
prefix "glob:", but I'm not sure which is better.
2025-11-12 11:27:41 +00:00
Yuya Nishihara
bb2647d687 matchers: add prefix matching support to GlobsMatcher
This will be used as a default matcher for patterns including glob characters. I
don't think prefix matching on globs would be particularly useful, but the
default behavior should be compatible with PrefixMatcher.

Regarding the implementation, a glob regex is first translated to a prefix
pattern by replacing $ with (/|$). We can instead use low-level regex_automata
API to compute prefix matching, but that would be more involved.
GlobMatcher::visit() is slightly optimized as we know descendant paths always
match.
2025-11-12 11:27:41 +00:00
Yuya Nishihara
9a69cf370a matchers: extract Visit::Specific { All, All } to private constant
Tests for glob matching use this extensively.
2025-11-12 11:27:41 +00:00
Scott Taylor
643318086a diff_util: replace [T; 2] with Diff<T>
I think using `Diff<T>` for these makes the code more readable, since
using 2-element arrays gives a less clear meaning to the arguments.
2025-11-10 14:41:44 +00:00