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

FR: Consider jj bookmark fastforward or similar #5927

Open
jaybosamiya opened this issue Mar 8, 2025 · 1 comment
Open

FR: Consider jj bookmark fastforward or similar #5927

jaybosamiya opened this issue Mar 8, 2025 · 1 comment

Comments

@jaybosamiya
Copy link

Is your feature request related to a problem? Please describe.
It might be nice for users to have a convenient way to move the "current branch" bookmark up (for workflows that are closer to git-like), rather than needing to manually specify the bookmark and the position to move to.

Describe the solution you'd like
jj bookmark fastforward (name/options/... could easily be bikeshed, I am more so talking about the semantics) would take the one "obvious" bookmark, and move it to the one "obvious" revision. If there isn't an obvious one for either, then it should not do anything, and instead request the user to use jj bookmark move.

Regarding "obvious":

  • one way to define an "obvious" bookmark is to be the nearest bookmark in the ancestors of @; possibly more restricted is to ensure it satisfies push-bookmark-prefix. I'm not sure how restricted we'd like this (possibly configurable by options)?
  • for an "obvious" target to move to: @ is pretty obvious, but we also probably don't want to use @ if it is an entirely empty commmit, in which case we probably want to use @-
  • the intention with "fast forward" naming is to have similar semantics to not allowing backwards moves

Describe alternatives you've considered
I am currently using this alias:

# Fast forward my latest bookmark on the current branch to the latest non-empty
# (or merge) commit.
ff = [
  "bookmark", "move",
  "--from", "latest(bookmarks(jayb) & ancestors(@))",
  "--to", "latest(ancestors(@) & (merges() | ~empty()))"
]

which works fine for my use case, but obviously it only works for people who share my name 🙃 It is possible I am not even using the ideal/fastest/optimal/... revsets here, but at least all the time that I've used it so far, it has not failed me (although I haven't used it particularly long). However, I suspect that this particular operation is common enough that it might be something to consider being a jj bookmark ... built-in command.

Additional context
Since there is a straightforward-enough workaround by adding an alias, I don't know how crucial adding such a feature is. It is possible this might just be an alias (with necessary updates to above example alias to make it more general/friendly) added to the docs, possibly here: https://jj-vcs.github.io/jj/latest/bookmarks/#ease-of-use

@PhilipMetzger
Copy link
Contributor

This is similar to #5667 and thus also relates to #3402, for now the alias is the best thing we can offer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants