Skip to content

FR: create bookmark pointing to new change #6246

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

Open
sersorrel opened this issue Apr 4, 2025 · 1 comment
Open

FR: create bookmark pointing to new change #6246

sersorrel opened this issue Apr 4, 2025 · 1 comment

Comments

@sersorrel
Copy link

Is your feature request related to a problem? Please describe.
In a megamerge workflow, I usually find myself in situations like this (diagram copied shamelessly from https://v5.chriskrycho.com/journal/jujutsu-megamerges-and-jj-absorb/):

            m --- n
           /       \
a -- [main] -- c -- [merge] -- @

If I want to start a new independent change, I can run something like jj new -A main -B merge --no-edit, to get something like:

            m --- n
           /       \
a -- [main] -- c -- [merge] -- @
           \       /
            -- w --

However, I like to leave a wip bookmark on the change I'm working on (so I can remember what I was doing after lunch, so that my shell prompt that shows me wip's description works properly, ...), and currently I have to manually jj b s wip -r w to do that. (actually just jj wip w, but I still have to read through the output of jj new to find the newly-created change ID, which is not always obvious.)

Describe the solution you'd like
I'd like to be able to run something like jj new -b wip to create/move the bookmark wip to the newly-created change in a single command.

Describe alternatives you've considered
I wanted to create an alias for this (jj newip or something), but I don't think it's easily possible, because you can't pass a template to jj new – I'd have to do some error-prone parsing (or inspect the op log, I guess?) to find the new change ID. Being able to jj new -T 'new_change_id()' or something like that would also probably solve this.

Additional context

If you're curious what I have in my prompt:
jj log --color always --no-graph -r '@|bookmarks(exact:"wip")' -T 'concat(separate(" ", label("bookmark", if(current_working_copy, "@")), label("bookmark", if(bookmarks, bookmarks.filter(|b| b.name() != "wip"))), format_short_change_id_with_hidden_and_divergent_info(self), if(empty, label("empty", "(empty)")), if(description, label("description", description.first_line()), label(if(empty, "empty"), description_placeholder))), "\n")'

It comes out looking like:

username@host:/wherever
@ szrkxrrp (empty) (no description set)
thunar-trash xnltntxt common: Patch Thunar to replace "Wastebasket" with "Trash"
$
@yuja
Copy link
Contributor

yuja commented Apr 5, 2025

Since jj doesn't have a "current bookmark", I don't think jj new -b/--bookmark would make much sense. Maybe we'll need a better scripting support?

Some related discussions:

api/scripting:
#3219
#3262
#3814

topic/rebase:
#3402
#4708

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