-
Notifications
You must be signed in to change notification settings - Fork 562
git: add jj git sync command #6826
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
base: main
Are you sure you want to change the base?
Conversation
Wrote it according #1039 (comment). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉 finally, here are some minor nits.
@@ -0,0 +1,403 @@ | |||
// Copyright 2020-2023 The Jujutsu Authors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: 2025 since its a new file
@@ -9,6 +9,7 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | |||
## [Unreleased] | |||
|
|||
### Release highlights | |||
* git: Introduce `jj git sync` for a `git pull --rebase`-like workflow across multiple bookmarks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: newline before the entry
pub struct GitSyncArgs { | ||
/// The remotes to sync with | ||
/// | ||
/// This defaults to the `git.fetch` setting. If that is not configured, and | ||
/// if there are multiple remotes, the remote named "origin" will be used. | ||
/// | ||
/// By default, the specified remote names match exactly. Use a [string | ||
/// pattern], e.g. `--remote 'glob:*'`, to select remotes using | ||
/// patterns. | ||
/// | ||
/// [string pattern]: | ||
/// https://jj-vcs.github.io/jj/latest/revsets#string-patterns | ||
#[arg( | ||
long = "remote", | ||
short = 'r', | ||
value_name = "REMOTE", | ||
value_parser = StringPattern::parse, | ||
add = ArgValueCandidates::new(complete::git_remotes), | ||
)] | ||
remotes: Vec<StringPattern>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: this is missing an argument with the bookmarks to create merge commits for, since that workflow also exists. I noted the same thing in the @essiene's design doc.
for (name, remote_ref) in tx.repo().view().remote_bookmarks(remote) { | ||
// Only capture non-conflicted targets | ||
if let Some(commit_id) = remote_ref.target.as_normal() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to use the local bookmark tracking the remote. Remote bookmarks often point to hidden commits.
// Perform the fetch (fetch all branches to properly handle merged/deleted | ||
// branches) | ||
let fetch_branches = vec![StringPattern::everything()]; | ||
do_git_fetch(ui, &mut tx, &remotes, &fetch_branches)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's probably better to use GitFetch
API. iirc, the idea was to add something like git_fetch.rebase_descendants()
. We might have to refactor import_refs()
to get enough information to rebase descendants of old bookmarks.
Checklist
If applicable:
CHANGELOG.md
README.md
,docs/
,demos/
)cli/src/config-schema.json
)Closes #1039