-
Notifications
You must be signed in to change notification settings - Fork 319
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: --advance-branches
flag for jj commit
#2338
Comments
I'd like this too. Some miscellaneous thoughts:
|
I think I've advocated in the past that Maybe there should be an option for |
EDIT: The below was in response to @necauqua's comment above. I'm concerned that not all users who do |
Well, I now realised that if we just have the flag (probably on both commands), then I can alias it anyway Especially since in personal repos I do anonymous heads and at work I have to maintain feature branches (and I do use the commit shortcut as much as it "un-coreness" bothers me, it's still a great shortcut) :) Such an alias (don't remember off the top of my head if you can alias used words like "ci/commit") could then be somewhere at the "useful aliases" page |
A simpler version of this idea: we could have a config that lists some names of branches that are not advanced by We could then think about whether we can define |
I'm a bit confused by the above conversation about |
Separately: I think in general, if I have to manually ...speaking of which, the fact that the "obvious" commit to choose is either |
|
Probably in addition to We could support a syntax along the lines of If more than one branch fits the description, it's unclear to me what's best (exit with an error or move them all).
|
It could be modeled as a "branch set" expression, but I would add a separate command |
I have been thinking about this, and if we can agree on the design, would like to help implement it. I have a few observations and questions, plus a possible design. I'll start by explicitly stating the intent of this issue as I understand it:
Here are some characteristics I'd like the solution to have:
Questions:
Anyway, given all of that, my proposal is that this new behavior should be added as a flag to Proposal in more detail:
|
@IlyaGar I'm not sure what you mean by this:
I thought this was basically what |
Does this issue arise from the difference in how The model in |
@joyously In git and jj, branches are indeed essentially tags. But they can still be useful locally without pushing them, so this should not be part of |
Perhaps it shouldn't be called a branch if it isn't one? Or define what a branch is in |
@joyously This is a bit of a tangent, I think, since the branch model is fairly well established and unlikely to change as part of this particular feature request. I'm not sure why or how "jj branches" and "git branches" could be distinguished, because they're the same concept; and when using This is a good, brief explanation of how to think about branches in |
Well, obviously they don't quite match or this new flag would not be needed. What I've heard is that If the |
@joyously I'm sorry, but you're mistaken: this request is not due
|
Sorry to barge into your conversation, we recently talked about renaming branches to bookmarks like Mercurial, which definitely fits better to the current We then should implement also something like topics, which are the canonical set of "named commits" which everybody knows. (See #2425 (comment)) |
That sounds good. But would that make For that, I think we'd need two conditions:
|
And since I'm here anyway.
This is pretty accurately describing the feature request.
Not really, only because it is a convience built-in, does not mean it is a
This functionality does not belong here, see #1039. And even then whats the reason for it?
This is also does not belong here, see #2977.
Answering both, no there are no special branches for
We fetch the default Git branch since, 0.14. But this is once again a pure Git concept which doesn't make sense in a Jujutsu world.
No,
Since this is mostly a crutch for Git users, implementing it on
👍
This is something @ilyagr implied with
The
This does not make sense with
👍
These kinda make sense, but should not be in the first cut.
I'd provide the interactive option only for ambigous branches, the other option makes sense.
This is a straight "No" from me. Maybe it has a place in your downstream if you find the time. |
Sorry, the above took a bit longer than expected.
Yes, it would make
Both provided options make more sense than providing a janky Git-like "branch". I'd assume |
@PhilipMetzger I think we have pretty different workflows and/or philosophies, but I do want to understand each of your points and where you're coming from.
Sorry, what is "it" here? Are you saying that
These seem at odds. I was suggestion a default-but-configurable behavior, but the "not in the first cut" comment is in response to a description of how the behavior would be configurable. The need for exclusions already came up in the original few comments in the thread, since
I'm assuming that by "this" here you mean "protected branches"? I'm not familiar with many version control systems, but I would be surprised if this is truly unique to Git forges. By "protected branch" I just mean "somewhere that you won't be allowed to push commits to." This is a feature of the remote (i.e. the forge, github/gitlab/etc), not of the version control system. But I acknowledge that, in general, this isn't something that's knowable from the local repository state, so it isn't something the tool should attempt to infer automatically.
I'm not sure what part doesn't make sense with
"Default branch" in the sense I'm using it here is another property of the forge rather than of the version control system. It simply means "the basis against which pull requests are compared, by default." This seems very non-git-specific to me. Any forge that supports any kind of pull-request-like feature needs some kind of basis for comparison. Even in a classic patch-based mailing-list system (i.e. without a forge), submitting patches still requires some way of indicating or assuming what version of the code the patch was generated against.
Thanks for clarifying. So the idea is that
I'm glad you agree that
I sort of assumed this would be the least-well-received part of my proposal, but I'd actually understand what's objectionable about it. (I'd also like to note that I think having a way to alias a sequence of commands would be a very useful feature that would make it completely unnecessary to have commands like In I understand that there's value in separating out each of these operations both in one's mental model and in the design of the tool. But the most common thing I do in version control is still a combination of all of these in quick succession: |
I think it's a kind of a "branch set expression" to select a branch name (just like a revset expression to select revisions.)
I think it would be a bit odd if btw, I usually go without named branches, and occasionally need to pull up the main branch locally. In that situation, a separate
Perhaps, this configuration will become a revset? |
I generally don't think we differ in workflows but mostly in philosophies, I just mentally moved on from Git and its branches quite a while ago.
"It" means
What I meant here, is to say that
Yes.
Yes, something similar exists in different version control systems but my issue with it is, that you only consider the Git/GitHub/Gitlab workflow in your solution. If you had to implement it for something Perforce-like or Mercurial-like, how would you proceed?
It atleast could consider
Ilya just made a suggestion which wasn't final at all. But agreed let's not open a bikeshed here.
I'm describing it as a "crutch for Git users", as other workflows manage fine with anonymous heads. See https://social.jvns.ca/@b0rk/111709458396281239 and this (requires a Discord account).
That totally is correct. I do think that you should try a workflow, where you don't immediately set a branch after a new commit as it vastly simplifies the usage of This is my answer for today, it took a good chunk of my evening, I'll try to explain my thoughts on the last part tomorrow or during the weekend. @BatmanAoD |
@PhilipMetzger Thanks for the detailed reply; but I'm sorry, I'm still extremely confused about whether branches are necessary or not.
If I don't set a branch, then I need to use |
Sorry it has taken me so long to get to this thread, and I still haven't read all of it.
No, that's not supported yet. I think we will want support for that eventually.
These seem inconsistent. I'd rather make both of the advance all branches. A configurable revset sounds as @yuja said might be good. Or maybe we even use jj log --no-graph -r 'heads(immutable_heads()..@ & branches())' -T 'local_branches ++ " "' | \
xargs jj branch set -r 'heads(immutable_heads()..@ ~ empty())' Consider putting that in a
I think @PhilipMetzger suggested that you create commits without moving branches and then move the branches just when you're about to push. (I very rarely move branches myself because GitHub takes care of moving the |
Here's the last part:
Basically my philosophy for new CLIs is that they should be composable and shouldn't special-case behaviors, as it is very confusing for new users which we're all at some point. Thus having a single command which does everything, as in Another point to consider with
There is absolutely nothing wrong with that, saying that as a big fan of automating everything and everywhere, it just doesn't fit in here. 🙁
This is in my opinion once again a workflow issue, which is only needed because Git is the dominant system. If we had a native repo + server where it didn't matter, it wouldn't cross your mind to use branches here.
No, what I meant is what Martin and Yuya in the previous comments said. Short description of the workflow below: You first build a stack commits of |
I honestly don't know. I'm not sure how much complexity would be added to translate the "current branch pointing to
|
From your second bullet point it sounds like you're describing a model where the branch sits at
But I think you're right that keeping the branch at the |
## TODO There is still a lot of work to do for this feature. We need to support `jj new`, and we need to add a `--branch` argument to `jj new` (and possibly `jj commit`) to resolve instances where more than one branch would be moved. The --branch option for `jj new` will allow users to create a new topic branch on top of an existing branch such as `main` without moving the `main` branch or needing to set an override for it in the config.toml. ## Feature Description If enabled in the user or repository settings, the local branch pointing to the revision targeted by `jj commit` will be advanced to the newly created commit. This behavior can be enabled by default for all branches by setting the following in the config.toml: ``` [branches] advance-branches = true ``` The default value of `advance-branches` is `false`. You can override the behavior for specific branches by setting the value of `advance-branches-overrides` in the config.toml: ``` [branches] advance-branches-overrides = ["main"] ``` Branches that have been overridden behave as if the value of `advance-branches` was negated. This implements FR #2338.
I think we're talking about different things. My proposal was to have the branch point to
Yes, it does seem complicated. Thanks for pointing that out, Yuya. |
I absolutely agree that having a branch automatically pointing at
|
I updated my prototype to move the branch to |
It's handled by Some related previous attempt: #2210 |
Thanks, I'll take a look at that PR. From #2338 (comment) the plan is to make this behavior strictly opt-in. You will be able to enable it globally, or only for certain branches. I'm optimistic that we can do this in a way that's useful for the people that want this feature, and a no-op for everyone else. |
I have a draft pull request up with a basic implementation. This is still WIP, but it's useable and supports automatically advancing branches with I'd appreciate if anyone interested in this feature takes a look at the explanation in the PR and tries it in a test repo to provide feedback. |
## Feature Description If enabled in the user or repository settings, the local branches pointing to the parents of the revision targeted by `jj commit` will be advanced to the newly created commit. Support for `jj new` will be added in a future change. This behavior can be enabled by default for all branches by setting the following in the config.toml: ``` [experimental-advance-branches] enabled-branches = ["glob:*"] ``` Specific branches can also be disabled: ``` [experimental-advance-branches] enabled-branches = ["glob:*"] disabled-branches = ["main"] ``` Branches that match a disabled pattern will not be advanced, even if they also match an enabled pattern. This implements feature request #2338. WIP: use patterns instead of overrides list to control advance-branches
## Feature Description If enabled in the user or repository settings, the local branches pointing to the parents of the revision targeted by `jj commit` will be advanced to the newly created commit. Support for `jj new` will be added in a future change. This behavior can be enabled by default for all branches by setting the following in the config.toml: ``` [experimental-advance-branches] enabled-branches = ["glob:*"] ``` Specific branches can also be disabled: ``` [experimental-advance-branches] enabled-branches = ["glob:*"] disabled-branches = ["main"] ``` Branches that match a disabled pattern will not be advanced, even if they also match an enabled pattern. This implements feature request #2338. WIP: use patterns instead of overrides list to control advance-branches
## Feature Description If enabled in the user or repository settings, the local branches pointing to the parents of the revision targeted by `jj commit` will be advanced to the newly created commit. Support for `jj new` will be added in a future change. This behavior can be enabled by default for all branches by setting the following in the config.toml: ``` [experimental-advance-branches] enabled-branches = ["glob:*"] ``` Specific branches can also be disabled: ``` [experimental-advance-branches] enabled-branches = ["glob:*"] disabled-branches = ["main"] ``` Branches that match a disabled pattern will not be advanced, even if they also match an enabled pattern. This implements feature request #2338. WIP: use patterns instead of overrides list to control advance-branches
## Feature Description If enabled in the user or repository settings, the local branches pointing to the parents of the revision targeted by `jj commit` will be advanced to the newly created commit. Support for `jj new` will be added in a future change. This behavior can be enabled by default for all branches by setting the following in the config.toml: ``` [experimental-advance-branches] enabled-branches = ["glob:*"] ``` Specific branches can also be disabled: ``` [experimental-advance-branches] enabled-branches = ["glob:*"] disabled-branches = ["main"] ``` Branches that match a disabled pattern will not be advanced, even if they also match an enabled pattern. This implements feature request #2338.
## Feature Description If enabled in the user or repository settings, the local branches pointing to the parents of the revision targeted by `jj commit` will be advanced to the newly created commit. Support for `jj new` will be added in a future change. This behavior can be enabled by default for all branches by setting the following in the config.toml: ``` [experimental-advance-branches] enabled-branches = ["glob:*"] ``` Specific branches can also be disabled: ``` [experimental-advance-branches] enabled-branches = ["glob:*"] disabled-branches = ["main"] ``` Branches that match a disabled pattern will not be advanced, even if they also match an enabled pattern. This implements feature request #2338.
## Feature Description If enabled in the user or repository settings, the local branches pointing to the parents of the revision targeted by `jj commit` will be advanced to the newly created commit. Support for `jj new` will be added in a future change. This behavior can be enabled by default for all branches by setting the following in the config.toml: ``` [experimental-advance-branches] enabled-branches = ["glob:*"] ``` Specific branches can also be disabled: ``` [experimental-advance-branches] enabled-branches = ["glob:*"] disabled-branches = ["main"] ``` Branches that match a disabled pattern will not be advanced, even if they also match an enabled pattern. This implements feature request #2338.
## Feature Description If enabled in the user or repository settings, the local branches pointing to the parents of the revision targeted by `jj commit` will be advanced to the newly created commit. Support for `jj new` will be added in a future change. This behavior can be enabled by default for all branches by setting the following in the config.toml: ``` [experimental-advance-branches] enabled-branches = ["glob:*"] ``` Specific branches can also be disabled: ``` [experimental-advance-branches] enabled-branches = ["glob:*"] disabled-branches = ["main"] ``` Branches that match a disabled pattern will not be advanced, even if they also match an enabled pattern. This implements feature request #2338.
## Feature Description If enabled in the user or repository settings, the local branches pointing to the parents of the revision targeted by `jj commit` will be advanced to the newly created commit. Support for `jj new` will be added in a future change. This behavior can be enabled by default for all branches by setting the following in the config.toml: ``` [experimental-advance-branches] enabled-branches = ["glob:*"] ``` Specific branches can also be disabled: ``` [experimental-advance-branches] enabled-branches = ["glob:*"] disabled-branches = ["main"] ``` Branches that match a disabled pattern will not be advanced, even if they also match an enabled pattern. This implements feature request #2338.
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 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: |
Based on @emesterhazy, could revsets or other types of patterns be implemented, such as Possibly this should be the default to prevent footguns? Or maybe at least the recommended default in the docs for enabling this. |
for updating the bookmark when addressing PR review feedback, i've found this alias handy (based on the v0.23 cli docs for
i run |
Took me a little to get that it's bookmark up and not a misspelled |
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 likejj commit -m [message] && jj branch set main -r @-
orjj 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 themain
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 tojj 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.
The text was updated successfully, but these errors were encountered: