-
Notifications
You must be signed in to change notification settings - Fork 404
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: Argument to jj git push
that creates a branch and immediately pushes it
#5472
Comments
Since in Then this issue would be solved by preventing a bookmark which has already been pushed to one remote from being pushed to a different remote. |
That's a good idea! It'd require me to change my workflow slightly, but not by much, and it sounds a lot easier. |
I think that's a bit different because I think it's a lot more similar to the |
I think it'd be OK to forbid We already treat a |
There are some devils in the details. Currently, my plan is to have
fail unless either As far as the remote is concerned, we'll use the usual rules (so, if the branch already existed, fast-forwards are allowed; anything else is considered a conflict and you are told to run If the remote branch exists and is untracked, we also fail (I think this is part of the "usual rules"). Let me know if you have thoughts. Is this worth having in this form? I've been using my draft version (without any detection of same-named branches), and it's been nice, though obviously not essential. Another alternative would be to make it more similar to
One reason I didn't like that is that it leads to a question: do we also add a Update: Also, this would create a possibility that the branch was moved but the push failed. On second thought, this seems important to avoid. I also considered recommending a shell script that does the above two commands, but that would mess up command-line completion for revisions. If aliases were powerful enough, we could perhaps go with that. Update: Though, again, this would create a possibility that the branch was moved but the push failed. |
If push failed within the same transaction, the created local bookmark would also disappear. So I think we can just recreate the same bookmark as FWIW, I don't like the UI that we have to pair up |
Ah, that's nice, good point! So, perhaps we can require the bookmark to not exist. I'm not sure whether or not there's harm in allowing the bookmark to exist at that commit, but not allowing it makes for easier code; we could start with that.
What do you mean?
+1 One possibility would be to assume
If I understand the idea correctly, we could add this in the future (using some sort of template that uses a character uncommon in bookmark names), or this could be a separate --name-prefix or --name-template option. |
Maybe it would be better if # Push bookmarks in default revset
jj git push
# Push bookmarks in specified revset
jj git push REVSET
# Create bookmark based on change ID at revset
jj git push REVSET --change
# Create bookmark at revset with given name
jj git push REVSET --create-bookmark NAME I'm not sure how well it would interact with |
There is also the distinction between "pushing every commit in a revset" and "pushing every bookmark in a revset". Currently, -c does the former and -r does the latter. We probably want to maintain this somehow, though perhaps there could be some short way to intersect a revset with --tracked and --all have more to do with -b, which is a third category, since the same revision can have multiple bookmarks. |
I just meant the same rule as
I agree it would be more confusing. My point was that
It's just to avoid "N change revisions" + "N name arguments" problem. The template argument would override the default |
Yeah, I didn't fully think it through and follow the logic, but I think -c currently makes different choices because the bookmark name it chooses is likely to be random and unique.
For now, my plan is to require it to expand to a single revision when |
It could also be separate arguments like I think it's best to make it work only with
We don't do anything like that anywhere else so I think it would be quite surprising. |
or single argument taking both name and revision |
Yes, that seems much better, especially since it can be repeated and be combined with the existing |
I don't know how strongly I feel about it, but I'm not sure why you dislike using I thought it was nice for
This could work, if we decide that this is worth introducing yet another flag that takes a revset to A few related more minor unordered thoughts on this topic: We seem to be reinventing refspecs. I'm worried this would be somewhat awkward to type, and to define shell completions for. I think clap allows a flag to take exactly two arguments,
I don't think this works, since All that said, we could try going with something like It's also possible there's a better way to reorganize |
What I don't like about
|
I think that the new option should be shorter, e.g. I'd like the latter name better, all else being equal, but then people will think that Either way, my gut feeling remains that it might be confusing to people to have an option like |
Ah, maybe |
How about |
It seems that the original request is asking for specifying remotes, but the discussion is focusing on naming bookmarks. |
Re my gut feeling, one thing that makes me feel better is that, with the current design, the user would get an immediate error if they confused
Sorry, I am not a huge fan. Again, the fact that such confusion results in an error and not misbehavior makes this better. So, I don't think Still, I think I'd prefer something like We can, of course, keep coming up with ideas; the name is easy to change.
I'm glad you think this might be more feasible in the future.
Scott hijacked the discussion with his idea in #5472 (comment) ; his proposal seemed to achieve vaguely the same effect (enough to satisfy my use-case) and be easier than what I was thinking. Thanks Scott!
Yuya suggested something similar in #5472 (comment) . I think, if that's all we did, it wouldn't quite satisfy the usecase in my mind, since I want exact control over the name. Still, it's an idea worth discussing, for example as part of a more overarching solution and/or the pursuit of merging --create-bookmark and --change (if it makes sense). I think I'd like, if possible, to implement some version of this idea relatively soon to see whether it helps with issues like #5512, so I don't mind postponing that overarching solution. |
jj git push
that creates a branch and immediately pushes it
Update: The original title of this issue was "FR: When creating a branch, I'd like to be able to specify some remote(s) it can be pushed to". Scott's reply below redirected my efforts.
Is your feature request related to a problem? Please describe.
I like and use the behavior where new branches are not pushed to remotes by default. In particular, I have some branches I only want to push to
origin
, and some I only want to push toupstream
(and sometimes perhaps some that get pushed to both)1.However, it is annoying to me that I cannot designate a branch as "this branch should be pushed to the origin" at the moment of its creation (when I usually am thinking about that).
Describe the solution you'd like
Perhaps
jj branch create --track origin
could create a branch that's pre-cleared to be pushed toorigin
, even withjj git push --tracked
.If we use this syntax, we might also want
jj branch track docs-single-page@origin
to work after creating the branch. Currently, it results inError: No such remote bookmark: docs-single-page@origin
Describe alternatives you've considered
I could, of course, disable this check entirely with #5094.
We could have
jj branch create --allow-push-to origin
, but then it'd be less clear whetherjj git push --tracked
should push it.This might introduce too much complexity to be worth implementing.
Another, possibly easier, option would be to implement
jj branch create br --push-to origin
that would push the branch immediately after creating it. OTOH, this would be slightly less convenient if the push fails, and it might be a good idea to keep all push/fetch functionality confined to those two commands.I'm not sure this is possible right now, but we could have a way to make a user command alias that creates a branch and immediately pushes it.
Footnotes
More details about my use-case: I usually have a
feature
branch that is only pushed toorigin
(my personal Github fork), and then at some point I create anig/feature
branch (at the same location) that I want to push (only) to upstream. different set of branches that I want to be pushed toorigin
. ↩The text was updated successfully, but these errors were encountered: