-
-
Notifications
You must be signed in to change notification settings - Fork 100
Reference: Revsets
See Revset recipes for some ideas and examples on how to use revsets.
The latest grammar is in grammar.lalrpop.
Names are resolved using the same logic as git rev-parse. Additionally, . is a synonym for HEAD.
The following functions are defined:
-
all(): all visible commits. -
none(): the empty set of commits. -
union(x, y): all commits that are in eitherxory. -
intersection(x, y): all commits that are in bothxandy. -
difference(x, y): all commits that are inxbut not iny. -
only(x, y): all commits which are ancestors ofx, but not ancestors ofy. -
range(x, y): all commits which are both descendants ofxand ancestors ofy. -
ancestors(x): all commits which are ancestors of commits inx.- A commit is an "ancestor" of
xif itxor it is a parent of an ancestor ofx. Note that this definition includesxitself in the set of ancestors ofx.
- A commit is an "ancestor" of
-
ancestors.nth(x, n): thenth generation ancestor ofx, following only the first parents. Equivalent to~n. -
descendants(x): all commits which are descendants of commits inx.- A commit is a "descendant" of
xif itxor it is a child of a descendant ofx. Note that this definition includesxitself in the set of descendants ofx.
- A commit is a "descendant" of
-
parents(x): all commits which are an immediate parent of a commit inx. -
parents.nth(x, n): thenth parent ofx. Equivalent to^n -
children(x): all commits which are an immediate child of a commit inx. -
roots(x): all commits inxwhich have no immediate ancestors also inx. -
heads(x): all commits inxwhich have no immediate descendants also inx. -
main(): the main branch commit. (New in master.) -
public(): all public commits, which is to say, all commits on the main branch. This is the same asancestors(main()). (New in master.) -
draft(): all draft commits. -
stack(x): all draft commits in the commit stack containingx. Without arguments, refers to the current commit stack (ie the one containingHEAD). -
message(text-pattern): all commits whose messages match the specified pattern. -
paths.changed(text-pattern): all commits with a changed file path matching the specified pattern. -
author.name(text-pattern): all commits whose author name matches the specified pattern. -
author.email(text-pattern): all commits whose author email matches the specified pattern. -
author.date(date-pattern): all commits whose author email matches the specified pattern. -
committer.name(text-pattern): all commits whose committer name matches the specified pattern. -
committer.email(text-pattern): all commits whose committer email matches the specified pattern. -
committer.date(date-pattern): all commits whose committer email matches the specified pattern. -
exactly(x, n): all commits inx, but only ifxcontains exactlyncommits. (New in v0.5.0.) -
current(x): the current version of all commits inx. (New in master.)- Commits in
xthat have been rewritten (for example, by being moved, reworded, amended, restacked, etc) will be resolved to their current version. Commits inxthat have not been rewritten will be included as is.
- Commits in
The following unary operations are defined:
-
:x: same asancestors(x).-
::xis also accepted to be familiar for Mercurial users.
-
-
x:: same asdescendants(x).-
x::is also accepted to be familiar for Mercurial users.
-
The following binary operations are defined:
-
+,|,or: same asunion. -
&,and: same asintersection. -
-: same asdifference.- Note that
foo-baris parsed as a branch name. To force the binary operation parsing, writefoo - barinstead.
- Note that
-
%: same asonly. -
:: same asrange.-
::is also accepted to be familiar for Mercurial users.
-
-
..: same asonly.
Text patterns:
-
foo,substr:foo,substring:foo: matches if the text containsfooanywhere. -
exact:foo: matches if the entire text content is exactlyfoo. -
glob:foo/*: matches if the text content matches the glob patternfoo/*anywhere. -
regex:foo.*: matches if the text content matches the glob patternfoo.*anywhere.
Dates can be either absolute (2022-01-01) or relative (1 month ago). Date patterns:
-
before:date: matches if the date is beforedate. -
after:date: matches if the date is afterdate.
Aliases may be defined via git config to provide easy access to oft used revset constructs. Parameters are supported, too: $1 will be replaced with the first parameter, $2 with the second, etc.
They can be defined from the command line:
$ git config --global \
branchless.revsets.alias.d \
"draft()"`
Or directly in the git config file:
[branchless "revsets.alias"]
grandChildren = children(children($1))
sole = exactly($1, 1)
onlyChild = sole(children($1))
onlyParent = sole(parents($1))
siblings = children(onlyParent($1)) - $1
Then, they can be used anywhere that git branchless accepts revsets:
$ git query 'd()'
...
$ git reword 'sole(siblings(abc123))'
...
- Search the Wiki 🔎
- User guide
- Welcome
- Installation
- Tutorial
- Command overview
- General:
- Navigation:
- Committing:
- Rebasing:
- Verification:
- Collaboration:
- Workflows
- Advanced topics
- Reference
- Developer guide
- Onboarding offer
- Development
- Reference