-
Notifications
You must be signed in to change notification settings - Fork 343
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
Add a branch option to jj new
#3793
Conversation
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
110ae76
to
3bc0101
Compare
Add a new option to the `jj new` command to automatically create or set a branch. For example `jj new -m "create fix" -b new_fix` will set the branch new_fix to the newly created commit. If the branch doesn't exist already, it will create it automatically for the user. The new flag is optional and can be used via the short form `-b` or the long form `--branch`. It takes one required argument which is the branch name.
I'm skeptical on copying Git-like named branch workflow in general, and I don't think this is compatible with the experimental advance-branches feature (#3129). It expects the current branch is set at #3402 might eventually implement a proper topic-branch support, but I don't know how that will be integrated with |
I'm also a bit skeptical of porting over the git branching model, and I'm not sure we should add branch manipulation to jj new as a flag. I wonder if the advance-branches feature that Yuya mentioned satisfies your use case. If your goal is to move a branch forward when you add commits i think it might be more convenient for doing that. Edit: it would also be good to understand your workflow a little better. I think it's more common to create a new branch once all of the work is done, so in your example the branch command wouldn't be run until after you've made changes and added any additional commits on top of the new one you created. I guess you know you will only create one commit and want to push it to a remote for a pull request? Why not use jj git push -c in that case? |
@emesterhazy I think my use case is even more simple than you are thinking. I don't need to auto move branches, I, probably like quite a few people here, prefer to set branches manually when ready to update. I absolutely agree that we should be careful about polluting the With this in mind, if others don't share my workflow, I'm happy to just add a short script on my machines that automates this initial commit process and let |
Separately from the issue of whether we should add a flag to |
Ok, so I think there are a few questions to answer here:
|
Maybe no? (see the comment below)
I don't think it's anti-pattern, but I think it's the workflow jj can't handle very well atm. In Git, branch name is mandatory in order to keep the commits alive, so there's a reason to do multiple things by one
iirc, there's a feature request to make it templatable. I think it'll be a config option (instead of command-line argument), but it might help if branch name can be somehow deduced from commit metadata (such as description.) |
I'm no longer convinced this should be merged as I haven't need it in a while, closing |
Adds a new flag to
jj new
calledbranch
(-b
or--branch
)Passing this flag creates a new branch with the given name or sets an existing branch to the new commit
Often, in my workflow, I create a commit and a branch at the same time.
Meaning I often perform the following two commands in series:
It would be nice to add a flag
-b
tojj new
just like-m
which also creates/sets a branch to the newly created commit like so:The setting of the branch (as opposed to creation) I'm not married to so if we want to just create new branches and error on existing branch names that is fine too.
Checklist
If applicable:
CHANGELOG.md