Find the closest bookmark in history to advance it forward #5568
|
When appending a new commit to a branch using |
Replies: 6 comments 21 replies
|
The revset to find the commit with the bookmark closest to Some people in the jj community have an alias they call [revset-aliases]
'closest_bookmark(to)' = 'heads(::to & bookmarks())'
[aliases]
tug = ["bookmark", "move", "--from", "closest_bookmark(@-)", "--to", "@-"]Usage: $ jj new my-feature
# work work work
$ jj commit -m "Add some changes"
$ jj tug
# The bookmark my-feature is now at @-If you want to move the bookmark to |
|
Read about the |
|
A slightly modified version that also works with the edit workflow: [revset-aliases]
'closest_bookmark(to)' = 'heads(::to & bookmarks())'
'closest_pushable(to)' = 'heads(::to & ~description(exact:"") & (~empty() | merges()))'
[aliases]
tug = ["bookmark", "move", "--from", "closest_bookmark(@)", "--to", "closest_pushable(@)"]Instead of moving the bookmark to the commit before the working copy, it moves the bookmark to the closest commit with a description that is either not empty or a merge. |
|
I'm trying to adapt some of the discussion here and at #6832 My goal is to select single closest bookmark for my prompt: It seems a bunch of issues stem from two problems:
https://jj-vcs.github.io/jj/latest/templates/#global-functions suggests that As a workaround, I can try to use Is there a way to get the first element of a |
|
I'm doing this a bit differently using a script: JJ_TUG.PS1 Doing it like this, a target revision can be specified (defaulting to @) and it won't move multiple bookmarks as "heads(::@ & bookmarks())" might in a environment where merging branches is common. |
#8830 introduces the
jj bookmark advancecommand, with customizablerevsets.bookmark-advance-toandrevsets.bookmark-advance-fromconfiguration.