Skip to content

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

git: add jj git sync command #6826

wants to merge 1 commit into from

Conversation

0xdeafbeef
Copy link
Member

Checklist

If applicable:

  • I have updated CHANGELOG.md
  • I have updated the documentation (README.md, docs/, demos/)
  • I have updated the config schema (cli/src/config-schema.json)
  • I have added/updated tests to cover my changes

Closes #1039

@0xdeafbeef 0xdeafbeef added the enhancement🏗️ New feature or request label Jun 25, 2025
@0xdeafbeef
Copy link
Member Author

Wrote it according #1039 (comment).

Copy link
Contributor

@PhilipMetzger PhilipMetzger left a 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
Copy link
Contributor

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.
Copy link
Contributor

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

Comment on lines +46 to +65
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>,
Copy link
Contributor

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.

Comment on lines +113 to +115
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() {
Copy link
Contributor

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)?;
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement🏗️ New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement jj sync command
3 participants