2024-04-05 12:39:59 +00:00
|
|
|
# Filesets
|
|
|
|
|
|
|
|
Jujutsu supports a functional language for selecting a set of files.
|
|
|
|
Expressions in this language are called "filesets" (the idea comes from
|
|
|
|
[Mercurial](https://repo.mercurial-scm.org/hg/help/filesets)). The language
|
2024-04-07 12:14:17 +00:00
|
|
|
consists of file patterns, operators, and functions.
|
2024-04-05 12:39:59 +00:00
|
|
|
|
2024-04-11 09:04:38 +00:00
|
|
|
**Filesets support is still experimental.** It can be enabled by
|
|
|
|
`ui.allow-filesets`.
|
|
|
|
|
|
|
|
```toml
|
|
|
|
ui.allow-filesets = true
|
|
|
|
```
|
|
|
|
|
2024-04-10 09:47:56 +00:00
|
|
|
Many `jj` commands accept fileset expressions as positional arguments. File
|
2024-04-17 12:17:40 +00:00
|
|
|
names passed to these commands [must be quoted][string-literals] if they contain
|
|
|
|
whitespace or meta characters. However, as a special case, quotes can be omitted
|
|
|
|
if the expression has no operators nor function calls. For example:
|
2024-04-10 09:47:56 +00:00
|
|
|
|
|
|
|
* `jj diff 'Foo Bar'` (shell quotes are required, but inner quotes are optional)
|
|
|
|
* `jj diff '~"Foo Bar"'` (both shell and inner quotes are required)
|
|
|
|
* `jj diff '"Foo(1)"'` (both shell and inner quotes are required)
|
|
|
|
|
2024-04-17 12:17:40 +00:00
|
|
|
[string-literals]: templates.md#string-literals
|
|
|
|
|
2024-04-05 12:39:59 +00:00
|
|
|
## File patterns
|
|
|
|
|
|
|
|
The following patterns are supported:
|
|
|
|
|
|
|
|
* `"path"`, `path` (the quotes are optional), or `cwd:"path"`: Matches
|
|
|
|
cwd-relative path prefix (file or files under directory recursively.)
|
|
|
|
* `cwd-file:"path"` or `file:"path"`: Matches cwd-relative file (or exact) path.
|
2024-04-14 02:33:55 +00:00
|
|
|
* `cwd-glob:"pattern"` or `glob:"pattern"`: Matches file paths with cwd-relative
|
|
|
|
Unix-style shell [wildcard `pattern`][glob]. For example, `glob:"*.c"` will
|
|
|
|
match all `.c` files in the current working directory non-recursively.
|
2024-04-05 12:39:59 +00:00
|
|
|
* `root:"path"`: Matches workspace-relative path prefix (file or files under
|
|
|
|
directory recursively.)
|
|
|
|
* `root-file:"path"`: Matches workspace-relative file (or exact) path.
|
2024-04-14 02:33:55 +00:00
|
|
|
* `root-glob:"pattern"`: Matches file paths with workspace-relative Unix-style
|
|
|
|
shell [wildcard `pattern`][glob].
|
|
|
|
|
|
|
|
[glob]: https://docs.rs/glob/latest/glob/struct.Pattern.html
|
2024-04-07 12:14:17 +00:00
|
|
|
|
|
|
|
## Operators
|
|
|
|
|
|
|
|
The following operators are supported. `x` and `y` below can be any fileset
|
|
|
|
expressions.
|
|
|
|
|
2024-06-06 07:19:26 +00:00
|
|
|
* `~x`: Matches everything but `x`.
|
2024-04-07 12:14:17 +00:00
|
|
|
* `x & y`: Matches both `x` and `y`.
|
|
|
|
* `x ~ y`: Matches `x` but not `y`.
|
2024-06-06 07:19:26 +00:00
|
|
|
* `x | y`: Matches either `x` or `y` (or both).
|
|
|
|
|
|
|
|
(listed in order of binding strengths)
|
2024-04-07 12:14:17 +00:00
|
|
|
|
|
|
|
You can use parentheses to control evaluation order, such as `(x & y) | z` or
|
|
|
|
`x & (y | z)`.
|
|
|
|
|
|
|
|
## Functions
|
|
|
|
|
|
|
|
You can also specify patterns by using functions.
|
|
|
|
|
|
|
|
* `all()`: Matches everything.
|
|
|
|
* `none()`: Matches nothing.
|
2024-04-08 07:43:18 +00:00
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
|
|
|
Show diff excluding `Cargo.lock`.
|
|
|
|
|
|
|
|
```
|
|
|
|
jj diff '~Cargo.lock'
|
|
|
|
```
|
|
|
|
|
2024-04-14 02:33:55 +00:00
|
|
|
List files in `src` excluding Rust sources.
|
|
|
|
|
|
|
|
```
|
|
|
|
jj files 'src ~ glob:"**/*.rs"'
|
|
|
|
```
|
|
|
|
|
2024-04-08 07:43:18 +00:00
|
|
|
Split a revision in two, putting `foo` into the second commit.
|
|
|
|
|
|
|
|
```
|
|
|
|
jj split '~foo'
|
|
|
|
```
|