martinvonz / jj

A Git-compatible VCS that is both simple and powerful
https://martinvonz.github.io/jj/
Apache License 2.0
8.39k stars 289 forks source link

FR: `--advance-branches` flag for `jj commit` #2338

Open emilykfox opened 1 year ago

emilykfox commented 1 year ago

Is your feature request related to a problem? Please describe. I often work directly on main for personal projects, but to successfully push my changes to GitHub, I have to run something like jj commit -m [message] && jj branch set main -r @- or jj branch set main && jj commit -m [message]. The former is error prone as it's easy to forget the -r flag. The latter feels slightly unnatural as there's a brief moment where the main branch is pointing to something without a description. They're both pretty verbose.

Describe the solution you'd like In Discord, @martinvonz suggested adding a --advance-branches flag to jj commit which could move any branches pointing to the old @- to point to the new @-.

Describe alternatives you've considered None

Additional context See the brief conversation starting at https://discord.com/channels/968932220549103686/969829516539228222/1159510245849186335.

Probably more important is that this feature would also improve workflows that involve adding several commits in sequence to a single feature branch.

emesterhazy commented 5 months ago

Oops, I accidentally closed this with:

I don't think this is fully resolved, since there are still a few open questions from that PR, and it might not be exactly what people want. But, if you just want your branches to move forward when you run jj commit and jj new this may be a solution for you. The instructions for setting this up are in the first comment in the PR.

This is an experimental feature that could be removed in the future. It should be available in the 0.17 release, or now if you build from source at head. Please leave any feedback here:

Cretezy commented 5 months ago

Based on @emesterhazy, could revsets or other types of patterns be implemented, such as thunk()? Having disabled-branches = ["thunk()"] seems like a useful way to declare this.

Possibly this should be the default to prevent footguns? Or maybe at least the recommended default in the docs for enabling this.