Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

revsets.md: clarify string patterns, and file patterns #2484

Merged
merged 1 commit into from
Nov 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 39 additions & 27 deletions docs/revsets.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,23 @@ revsets (expressions) as arguments.
* `none()`: No commits. This function is rarely useful; it is provided for
completeness.
* `branches([pattern])`: All local branch targets. If `pattern` is specified,
branches whose name contains the given string are selected. For example,
`branches(push)` would match the branches `push-123` and `repushed` but not
the branch `main`. If a branch is in a conflicted state, all its possible
targets are included.
* `remote_branches([branch_pattern[, [remote=]remote_pattern]])`: All remote
branch targets across all remotes. If just the `branch_pattern` is specified,
branches whose name contains the given string across all remotes are
selected. If both `branch_pattern` and `remote_pattern` are specified, the
selection is further restricted to just the remotes whose name contains
`remote_pattern`. For example, `remote_branches(push, ri)` would match the
branches `push-123@origin` and `repushed@private` but not `push-123@upstream`
or `main@origin` or `main@upstream`. If a branch is in a conflicted state,
all its possible targets are included.
this selects the branches whose name match the given [string
pattern](#string-patterns). For example, `branches(push)` would match the
branches `push-123` and `repushed` but not the branch `main`. If a branch is
in a conflicted state, all its possible targets are included.

* `remote_branches([branch_pattern[, [remote=]remote_pattern]])`: All remote
ilyagr marked this conversation as resolved.
Show resolved Hide resolved
branch targets across all remotes. If just the `branch_pattern` is
specified, the branches whose names match the given [string
pattern](#string-patterns) across all remotes are selected. If both
`branch_pattern` and `remote_pattern` are specified, the selection is
further restricted to just the remotes whose names match `remote_pattern`.

For example, `remote_branches(push, ri)` would match the branches
`push-123@origin` and `repushed@private` but not `push-123@upstream` or
`main@origin` or `main@upstream`. If a branch is in a conflicted state, all
its possible targets are included.

* `tags()`: All tag targets. If a tag is in a conflicted state, all its
possible targets are included.
* `git_refs()`: All Git ref targets as of the last import. If a Git ref
Expand All @@ -120,32 +124,40 @@ revsets (expressions) as arguments.
* `latest(x[, count])`: Latest `count` commits in `x`, based on committer
timestamp. The default `count` is 1.
* `merges()`: Merge commits.
* `description(pattern)`: Commits with the given string in their
description.
* `author(pattern)`: Commits with the given string in the author's name or
email.
* `description(pattern)`: Commits that have a description matching the given
[string pattern](#string-patterns).
* `author(pattern)`: Commits with the author's name or email matching the given
[string pattern](#string-patterns).
* `mine()`: Commits where the author's email matches the email of the current
user.
* `committer(pattern)`: Commits with the given string in the committer's
name or email.
* `committer(pattern)`: Commits with the committer's name or email matching the
given [string pattern](#string-patterns).
* `empty()`: Commits modifying no files. This also includes `merges()` without
user modifications and `root()`.
* `file(pattern..)`: Commits modifying the paths specified by the `pattern..`.
Paths are relative to the directory `jj` was invoked from. A directory name
will match all files in that directory and its subdirectories. For example,
`file(foo)` will match files `foo`, `foo/bar`, `foo/bar/baz`, but not file
`foobar`.

* `file(relativepath)` or `file("relativepath"[, "relativepath"]...)`: Commits
modifying one of the paths specified. Currently, string patterns are *not*
supported in the path arguments.

Paths are relative to the directory `jj` was invoked from. A directory name
will match all files in that directory and its subdirectories.

For example, `file(foo)` will match files `foo`, `foo/bar`, `foo/bar/baz`.
It will *not* match `foobar` or `bar/foo`.

* `conflict()`: Commits with conflicts.
* `present(x)`: Same as `x`, but evaluated to `none()` if any of the commits
in `x` doesn't exist (e.g. is an unknown branch name.)

## String patterns

Functions that perform string matching support the following pattern syntax.
Functions that perform string matching support the following pattern syntax:

* `"string"`, `substring:"string"`: Matches strings that contain `string`.
* `"string"`, or `string` (the quotes are optional), or `substring:"string"`:
Matches strings that contain `string`.
* `exact:"string"`: Matches strings exactly equal to `string`.
* `glob:"pattern"`: Matches strings with Unix-style shell wildcard `pattern`.
* `glob:"pattern"`: Matches strings with Unix-style shell [wildcard
`pattern`](https://docs.rs/glob/latest/glob/struct.Pattern.html).

## Aliases

Expand Down