forked from mirrors/jj
templater: add root
keyword
Similar to other boolean flags, such as "working_copy" or "empty". We could test something like `"0000000000000000000000000000000000000000".contains(commit_id)` like I did for myself, but first of all this is ugly, and secondly the root commit id is not guaranteed to be 40 zeroes as custom backend implementations could have some other root.
This commit is contained in:
parent
9138bb5517
commit
82923afcc5
4 changed files with 9 additions and 1 deletions
|
@ -31,6 +31,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
### New features
|
||||
|
||||
* Commit templates now support the `root` keyword, which is `true` for the root
|
||||
commit and `false` for every other commit.
|
||||
|
||||
* `jj init --git-repo` now works with bare repositories.
|
||||
|
||||
* `jj config edit --user` and `jj config set --user` will now pick a default
|
||||
|
|
|
@ -306,6 +306,9 @@ fn build_commit_keyword_opt<'repo>(
|
|||
let parent_tree = rewrite::merge_commit_trees(repo, &commit.parents()).unwrap();
|
||||
commit.tree_id() == parent_tree.id()
|
||||
})),
|
||||
"root" => language.wrap_boolean(wrap_fn(property, move |commit| {
|
||||
commit.id() == repo.store().root_commit_id()
|
||||
})),
|
||||
_ => return None,
|
||||
};
|
||||
Some(property)
|
||||
|
|
|
@ -175,7 +175,8 @@
|
|||
"is_git_head",
|
||||
"divergent",
|
||||
"hidden",
|
||||
"conflict"
|
||||
"conflict",
|
||||
"root"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
|
|
@ -34,6 +34,7 @@ The following keywords can be used in `jj log`/`jj obslog` templates.
|
|||
* `hidden: Boolean`: True if the commit is not visible (a.k.a. abandoned).
|
||||
* `conflict: Boolean`: True if the commit contains merge conflicts.
|
||||
* `empty: Boolean`: True if the commit modifies no files.
|
||||
* `root: Boolean`: True if the commit is the root commit.
|
||||
|
||||
### Operation keywords
|
||||
|
||||
|
|
Loading…
Reference in a new issue