From 0ff8a4e840988158aa7e0ce2f9ab9425b1de0b47 Mon Sep 17 00:00:00 2001 From: Essien Ita Essien <34972+essiene@users.noreply.github.com> Date: Sat, 2 Nov 2024 11:04:02 +0000 Subject: [PATCH] git sync: unhide `jj git sync` ## Summary * [X] Get branch pre-fetch heads * [X] Build candidates from prefetch heads * [X] Fetch from remotes * [X] Get branch post-fetch heads * [X] Rebase * [X] Build old -> new map * [X] transform descendants ## Details * Add tests * Unhide the command, now that it's complete. * Update CHANGELOG Issue: #1039 --- CHANGELOG.md | 2 ++ cli/src/commands/git/mod.rs | 1 - cli/tests/cli-reference@.md.snap | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ad6f28658..05ca28d20d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,8 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ### New features +* Implement `jj git sync`. + * Templates now support the `==` and `!=` logical operators for `Boolean`, `Integer`, and `String` types. diff --git a/cli/src/commands/git/mod.rs b/cli/src/commands/git/mod.rs index f43a3e11bf..da2c783600 100644 --- a/cli/src/commands/git/mod.rs +++ b/cli/src/commands/git/mod.rs @@ -64,7 +64,6 @@ pub enum GitCommand { Remote(RemoteCommand), #[command(subcommand, hide = true)] Submodule(GitSubmoduleCommand), - #[command(hide = true)] Sync(GitSyncArgs), } diff --git a/cli/tests/cli-reference@.md.snap b/cli/tests/cli-reference@.md.snap index e3da2f4863..6d24b69470 100644 --- a/cli/tests/cli-reference@.md.snap +++ b/cli/tests/cli-reference@.md.snap @@ -1,6 +1,7 @@ --- source: cli/tests/test_generate_md_cli_help.rs description: "AUTO-GENERATED FILE, DO NOT EDIT. This cli reference is generated by a test as an `insta` snapshot. MkDocs includes this snapshot from docs/cli-reference.md." +snapshot_kind: text --- @@ -59,6 +60,7 @@ This document contains the help content for the `jj` command-line program. * [`jj git remote remove`↴](#jj-git-remote-remove) * [`jj git remote rename`↴](#jj-git-remote-rename) * [`jj git remote set-url`↴](#jj-git-remote-set-url) +* [`jj git sync`↴](#jj-git-sync) * [`jj help`↴](#jj-help) * [`jj init`↴](#jj-init) * [`jj interdiff`↴](#jj-interdiff) @@ -1049,6 +1051,7 @@ For a comparison with Git, including a table of commands, see https://martinvonz * `init` — Create a new Git backed repo * `push` — Push to a Git remote * `remote` — Manage Git remotes +* `sync` — Sync the local `jj` repo to remote Git branch(es) @@ -1263,6 +1266,35 @@ Set the URL of a Git remote +## `jj git sync` + +Sync the local `jj` repo to remote Git branch(es). + +The sync command will first fetch from the Git remote(s), then rebase all local changes onto the appropriate updated heads that were fetched. + +Changes that are made empty by the rebase are dropped. + +**Usage:** `jj git sync [OPTIONS]` + +###### **Options:** + +* `-b`, `--branch ` — Rebase the specified branches only. + + Note that this affects only the rebase behaviour, as the fetch behaviour always fetches all branches. + + By default, the specified name matches exactly. Use `glob:` prefix to expand `*` as a glob. The other wildcard characters aren't supported. + + Default value: `glob:*` +* `--all-remotes` — Fetch from all remotes + + By default, the fetch will only use remotes configured in the `git.fetch` section of the config. + + When specified, --all-remotes causes the fetch to use all remotes known to the underlying git repo. + + Default value: `false` + + + ## `jj help` Print this message or the help of the given subcommand(s)