diff --git a/CHANGELOG.md b/CHANGELOG.md index 241bf4b50..d86610c67 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,11 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). * `remotes..auto-track-bookmarks` is now parsed the same way they are in revsets and can be combined with logical operators. +* `jj bookmark track`/`untrack` now accepts `--remote` argument. If omitted, all + remote bookmarks matching the bookmark names will be tracked/untracked. The + old `@` syntax is deprecated in favor of ` + --remote=`. + * On Windows, symlinks that point to a path with `/` won't be supported. This path is [invalid on Windows]. diff --git a/cli/src/cli_util.rs b/cli/src/cli_util.rs index 5fa8641a8..8c66edbc8 100644 --- a/cli/src/cli_util.rs +++ b/cli/src/cli_util.rs @@ -3111,8 +3111,9 @@ impl DiffSelector { } } +// TODO: Delete in jj 0.43+ #[derive(Clone, Debug)] -pub struct RemoteBookmarkNamePattern { +pub(crate) struct RemoteBookmarkNamePattern { pub bookmark: StringPattern, pub remote: StringPattern, } diff --git a/cli/src/commands/bookmark/mod.rs b/cli/src/commands/bookmark/mod.rs index 0674f48db..9023814de 100644 --- a/cli/src/commands/bookmark/mod.rs +++ b/cli/src/commands/bookmark/mod.rs @@ -30,6 +30,7 @@ use jj_lib::iter_util::fallible_any; use jj_lib::op_store::RefTarget; use jj_lib::op_store::RemoteRef; use jj_lib::ref_name::RefName; +use jj_lib::ref_name::RemoteName; use jj_lib::ref_name::RemoteRefSymbol; use jj_lib::repo::Repo; use jj_lib::str_util::StringExpression; @@ -218,3 +219,20 @@ fn warn_unmatched_local_or_remote_bookmarks( names.map(|name| name.as_symbol()).join(", ") ) } + +/// Warns about exact patterns that don't match remotes. +fn warn_unmatched_remotes(ui: &Ui, view: &View, name_expr: &StringExpression) -> io::Result<()> { + let mut names = name_expr + .exact_strings() + .map(RemoteName::new) + .filter(|name| view.get_remote_view(name).is_none()) + .peekable(); + if names.peek().is_none() { + return Ok(()); + } + writeln!( + ui.warning_default(), + "No matching remotes for names: {}", + names.map(|name| name.as_symbol()).join(", ") + ) +} diff --git a/cli/src/commands/bookmark/track.rs b/cli/src/commands/bookmark/track.rs index c8d79b5e6..5ad71e830 100644 --- a/cli/src/commands/bookmark/track.rs +++ b/cli/src/commands/bookmark/track.rs @@ -17,13 +17,21 @@ use std::rc::Rc; use clap_complete::ArgValueCandidates; use itertools::Itertools as _; +use jj_lib::repo::Repo as _; +use jj_lib::str_util::StringExpression; use super::find_trackable_remote_bookmarks; +use super::trackable_remote_bookmarks_matching; +use super::warn_unmatched_local_or_remote_bookmarks; +use super::warn_unmatched_remotes; use crate::cli_util::CommandHelper; use crate::cli_util::RemoteBookmarkNamePattern; +use crate::cli_util::default_ignored_remote_name; use crate::command_error::CommandError; +use crate::command_error::cli_error; use crate::commit_templater::CommitRef; use crate::complete; +use crate::revset_util::parse_union_name_patterns; use crate::templater::TemplateRenderer; use crate::ui::Ui; @@ -34,21 +42,32 @@ use crate::ui::Ui; /// pulls. #[derive(clap::Args, Clone, Debug)] pub struct BookmarkTrackArgs { - /// Remote bookmarks to track + /// Bookmark names to track /// /// By default, the specified name matches exactly. Use `glob:` prefix to /// select bookmarks by [wildcard pattern]. /// - /// Examples: bookmark@remote, glob:main@*, glob:jjfan-*@upstream - /// /// [wildcard pattern]: /// https://docs.jj-vcs.dev/latest/revsets/#string-patterns #[arg( required = true, - value_name = "BOOKMARK@REMOTE", + value_name = "BOOKMARK", add = ArgValueCandidates::new(complete::untracked_bookmarks), )] - names: Vec, + names: Vec, + + /// Remote names to track + /// + /// By default, the specified name matches exactly. Use `glob:` prefix to + /// select bookmarks by [wildcard pattern]. + /// + /// If no remote names are given, all remote bookmarks matching the bookmark + /// names will be tracked. + /// + /// [wildcard pattern]: + /// https://docs.jj-vcs.dev/latest/revsets/#string-patterns + #[arg(long = "remote", value_name = "REMOTE")] + remotes: Option>, } pub fn cmd_bookmark_track( @@ -58,8 +77,40 @@ pub fn cmd_bookmark_track( ) -> Result<(), CommandError> { let mut workspace_command = command.workspace_helper(ui)?; let repo = workspace_command.repo().clone(); + let view = repo.view(); + let matched_refs = if args.remotes.is_none() && args.names.iter().all(|s| s.contains('@')) { + // TODO: Delete in jj 0.43+ + writeln!( + ui.warning_default(), + "@ syntax is deprecated, use ` --remote=` instead." + )?; + let name_patterns: Vec = args + .names + .iter() + .map(|s| s.parse()) + .try_collect() + .map_err(cli_error)?; + find_trackable_remote_bookmarks(ui, view, &name_patterns)? + } else { + let ignored_remote = default_ignored_remote_name(repo.store()) + // suppress unmatched remotes warning for default-ignored remote + .filter(|name| view.get_remote_view(name).is_some()); + let bookmark_expr = parse_union_name_patterns(ui, &args.names)?; + let remote_expr = match (&args.remotes, ignored_remote) { + (Some(text), _) => parse_union_name_patterns(ui, text)?, + (None, Some(ignored)) => StringExpression::exact(ignored).negated(), + (None, None) => StringExpression::all(), + }; + let bookmark_matcher = bookmark_expr.to_matcher(); + let remote_matcher = remote_expr.to_matcher(); + let matched_refs = + trackable_remote_bookmarks_matching(view, &bookmark_matcher, &remote_matcher).collect(); + warn_unmatched_local_or_remote_bookmarks(ui, view, &bookmark_expr)?; + warn_unmatched_remotes(ui, view, &remote_expr)?; + matched_refs + }; let mut symbols = Vec::new(); - for (symbol, remote_ref) in find_trackable_remote_bookmarks(ui, repo.view(), &args.names)? { + for (symbol, remote_ref) in matched_refs { if remote_ref.is_tracked() { writeln!( ui.warning_default(), diff --git a/cli/src/commands/bookmark/untrack.rs b/cli/src/commands/bookmark/untrack.rs index 9d7b1881a..1b3c6e9e9 100644 --- a/cli/src/commands/bookmark/untrack.rs +++ b/cli/src/commands/bookmark/untrack.rs @@ -15,13 +15,19 @@ use clap_complete::ArgValueCandidates; use itertools::Itertools as _; use jj_lib::repo::Repo as _; +use jj_lib::str_util::StringExpression; use super::find_trackable_remote_bookmarks; +use super::trackable_remote_bookmarks_matching; +use super::warn_unmatched_local_or_remote_bookmarks; +use super::warn_unmatched_remotes; use crate::cli_util::CommandHelper; use crate::cli_util::RemoteBookmarkNamePattern; use crate::cli_util::default_ignored_remote_name; use crate::command_error::CommandError; +use crate::command_error::cli_error; use crate::complete; +use crate::revset_util::parse_union_name_patterns; use crate::ui::Ui; /// Stop tracking given remote bookmarks @@ -33,21 +39,32 @@ use crate::ui::Ui; /// corresponding remote bookmarks, use `jj bookmark forget` instead. #[derive(clap::Args, Clone, Debug)] pub struct BookmarkUntrackArgs { - /// Remote bookmarks to untrack + /// Bookmark names to untrack /// /// By default, the specified name matches exactly. Use `glob:` prefix to /// select bookmarks by [wildcard pattern]. /// - /// Examples: bookmark@remote, glob:main@*, glob:jjfan-*@upstream - /// /// [wildcard pattern]: /// https://docs.jj-vcs.dev/latest/revsets/#string-patterns #[arg( required = true, - value_name = "BOOKMARK@REMOTE", + value_name = "BOOKMARK", add = ArgValueCandidates::new(complete::tracked_bookmarks) )] - names: Vec, + names: Vec, + + /// Remote names to untrack + /// + /// By default, the specified name matches exactly. Use `glob:` prefix to + /// select bookmarks by [wildcard pattern]. + /// + /// If no remote names are given, all remote bookmarks matching the bookmark + /// names will be untracked. + /// + /// [wildcard pattern]: + /// https://docs.jj-vcs.dev/latest/revsets/#string-patterns + #[arg(long = "remote", value_name = "REMOTE")] + remotes: Option>, } pub fn cmd_bookmark_untrack( @@ -57,9 +74,40 @@ pub fn cmd_bookmark_untrack( ) -> Result<(), CommandError> { let mut workspace_command = command.workspace_helper(ui)?; let repo = workspace_command.repo().clone(); - let ignored_remote = default_ignored_remote_name(repo.store()); + let view = repo.view(); + let ignored_remote = default_ignored_remote_name(repo.store()) + // suppress unmatched remotes warning for default-ignored remote + .filter(|name| view.get_remote_view(name).is_some()); + let matched_refs = if args.remotes.is_none() && args.names.iter().all(|s| s.contains('@')) { + // TODO: Delete in jj 0.43+ + writeln!( + ui.warning_default(), + "@ syntax is deprecated, use ` --remote=` instead." + )?; + let name_patterns: Vec = args + .names + .iter() + .map(|s| s.parse()) + .try_collect() + .map_err(cli_error)?; + find_trackable_remote_bookmarks(ui, view, &name_patterns)? + } else { + let bookmark_expr = parse_union_name_patterns(ui, &args.names)?; + let remote_expr = match (&args.remotes, ignored_remote) { + (Some(text), _) => parse_union_name_patterns(ui, text)?, + (None, Some(ignored)) => StringExpression::exact(ignored).negated(), + (None, None) => StringExpression::all(), + }; + let bookmark_matcher = bookmark_expr.to_matcher(); + let remote_matcher = remote_expr.to_matcher(); + let matched_refs = + trackable_remote_bookmarks_matching(view, &bookmark_matcher, &remote_matcher).collect(); + warn_unmatched_local_or_remote_bookmarks(ui, view, &bookmark_expr)?; + warn_unmatched_remotes(ui, view, &remote_expr)?; + matched_refs + }; let mut symbols = Vec::new(); - for (symbol, remote_ref) in find_trackable_remote_bookmarks(ui, repo.view(), &args.names)? { + for (symbol, remote_ref) in matched_refs { if ignored_remote.is_some_and(|ignored| symbol.remote == ignored) { // This restriction can be lifted if we want to support untracked @git // bookmarks. diff --git a/cli/tests/cli-reference@.md.snap b/cli/tests/cli-reference@.md.snap index 7c29ccd76..62678912b 100644 --- a/cli/tests/cli-reference@.md.snap +++ b/cli/tests/cli-reference@.md.snap @@ -557,17 +557,25 @@ Start tracking given remote bookmarks A tracking remote bookmark will be imported as a local bookmark of the same name. Changes to it will propagate to the existing local bookmark on future pulls. -**Usage:** `jj bookmark track ...` +**Usage:** `jj bookmark track [OPTIONS] ...` **Command Alias:** `t` ###### **Arguments:** -* `` — Remote bookmarks to track +* `` — Bookmark names to track By default, the specified name matches exactly. Use `glob:` prefix to select bookmarks by [wildcard pattern]. - Examples: bookmark@remote, glob:main@*, glob:jjfan-*@upstream + [wildcard pattern]: https://docs.jj-vcs.dev/latest/revsets/#string-patterns + +###### **Options:** + +* `--remote ` — Remote names to track + + By default, the specified name matches exactly. Use `glob:` prefix to select bookmarks by [wildcard pattern]. + + If no remote names are given, all remote bookmarks matching the bookmark names will be tracked. [wildcard pattern]: https://docs.jj-vcs.dev/latest/revsets/#string-patterns @@ -581,15 +589,23 @@ A non-tracking remote bookmark is just a pointer to the last-fetched remote book If you want to forget a local bookmark while also untracking the corresponding remote bookmarks, use `jj bookmark forget` instead. -**Usage:** `jj bookmark untrack ...` +**Usage:** `jj bookmark untrack [OPTIONS] ...` ###### **Arguments:** -* `` — Remote bookmarks to untrack +* `` — Bookmark names to untrack By default, the specified name matches exactly. Use `glob:` prefix to select bookmarks by [wildcard pattern]. - Examples: bookmark@remote, glob:main@*, glob:jjfan-*@upstream + [wildcard pattern]: https://docs.jj-vcs.dev/latest/revsets/#string-patterns + +###### **Options:** + +* `--remote ` — Remote names to untrack + + By default, the specified name matches exactly. Use `glob:` prefix to select bookmarks by [wildcard pattern]. + + If no remote names are given, all remote bookmarks matching the bookmark names will be untracked. [wildcard pattern]: https://docs.jj-vcs.dev/latest/revsets/#string-patterns diff --git a/cli/tests/test_bookmark_command.rs b/cli/tests/test_bookmark_command.rs index 1129995c7..7c1bbc394 100644 --- a/cli/tests/test_bookmark_command.rs +++ b/cli/tests/test_bookmark_command.rs @@ -368,9 +368,7 @@ fn test_bookmark_move() { "); // Untracked remote bookmark shouldn't block creation of local bookmark - work_dir - .run_jj(["bookmark", "untrack", "foo@origin"]) - .success(); + work_dir.run_jj(["bookmark", "untrack", "foo"]).success(); work_dir.run_jj(["bookmark", "delete", "foo"]).success(); let output = work_dir.run_jj(["bookmark", "create", "foo"]); insta::assert_snapshot!(output, @r" @@ -692,7 +690,7 @@ fn test_bookmark_rename() { // rename an untracked bookmark work_dir - .run_jj(["bookmark", "untrack", "buntracked@origin"]) + .run_jj(["bookmark", "untrack", "buntracked"]) .success(); let output = work_dir.run_jj(["bookmark", "rename", "buntracked", "buntracked2"]); insta::assert_snapshot!(output, @""); @@ -819,9 +817,7 @@ fn test_bookmark_delete_glob() { work_dir.run_jj(["git", "push", "--all"]).success(); // Add absent-tracked bookmark work_dir.run_jj(["bookmark", "create", "foo-5"]).success(); - work_dir - .run_jj(["bookmark", "track", "foo-5@origin"]) - .success(); + work_dir.run_jj(["bookmark", "track", "foo-5"]).success(); let setup_opid = work_dir.current_operation_id(); insta::assert_snapshot!(get_log_output(&work_dir), @r" @@ -1245,9 +1241,13 @@ fn test_bookmark_track_untrack() { "); // Track new bookmark. Local bookmark should be created. - work_dir - .run_jj(["bookmark", "track", "feature1@origin", "main@origin"]) - .success(); + let output = work_dir.run_jj(["bookmark", "track", "feature1@origin", "main@origin"]); + insta::assert_snapshot!(output, @r" + ------- stderr ------- + Warning: @ syntax is deprecated, use ` --remote=` instead. + Started tracking 2 remote bookmarks. + [EOF] + "); insta::assert_snapshot!(get_bookmark_output(&work_dir), @r" feature1: qxxqrkql bd843888 commit 1 @origin: qxxqrkql bd843888 commit 1 @@ -1258,10 +1258,10 @@ fn test_bookmark_track_untrack() { "); // Track non-existent remote bookmark - let output = work_dir.run_jj(["bookmark", "track", "feature3@origin"]); + let output = work_dir.run_jj(["bookmark", "track", "feature3", "--remote=origin"]); insta::assert_snapshot!(output, @r" ------- stderr ------- - Warning: No matching remote bookmarks for names: feature3@origin + Warning: No matching bookmarks for names: feature3 Nothing changed. [EOF] "); @@ -1270,9 +1270,7 @@ fn test_bookmark_track_untrack() { work_dir .run_jj(["bookmark", "create", "-r@", "feature2"]) .success(); - work_dir - .run_jj(["bookmark", "track", "feature2@origin"]) - .success(); + work_dir.run_jj(["bookmark", "track", "feature2"]).success(); insta::assert_snapshot!(get_bookmark_output(&work_dir), @r" feature1: qxxqrkql bd843888 commit 1 @origin: qxxqrkql bd843888 commit 1 @@ -1290,9 +1288,13 @@ fn test_bookmark_track_untrack() { work_dir .run_jj(["bookmark", "delete", "feature2"]) .success(); - work_dir - .run_jj(["bookmark", "untrack", "feature1@origin", "feature2@origin"]) - .success(); + let output = work_dir.run_jj(["bookmark", "untrack", "feature1@origin", "feature2@origin"]); + insta::assert_snapshot!(output, @r" + ------- stderr ------- + Warning: @ syntax is deprecated, use ` --remote=` instead. + Stopped tracking 2 remote bookmarks. + [EOF] + "); insta::assert_snapshot!(get_bookmark_output(&work_dir), @r" feature1: qxxqrkql bd843888 commit 1 feature1@origin: qxxqrkql bd843888 commit 1 @@ -1438,9 +1440,9 @@ fn test_bookmark_track_conflict() { // stop and retrack origin; creates conflict // origin2 and origin3 are not shown work_dir - .run_jj(["bookmark", "untrack", "main@origin"]) + .run_jj(["bookmark", "untrack", "main", "--remote=origin"]) .success(); - let output = work_dir.run_jj(["bookmark", "track", "main@origin"]); + let output = work_dir.run_jj(["bookmark", "track", "main", "--remote=origin"]); insta::assert_snapshot!(output, @r" ------- stderr ------- Started tracking 1 remote bookmarks. @@ -1464,9 +1466,9 @@ fn test_bookmark_track_conflict() { // retracking origin2 adds to the conflict work_dir - .run_jj(["bookmark", "untrack", "main@origin2"]) + .run_jj(["bookmark", "untrack", "main", "--remote=origin2"]) .success(); - let output = work_dir.run_jj(["bookmark", "track", "main@origin2"]); + let output = work_dir.run_jj(["bookmark", "track", "main", "--remote=origin2"]); insta::assert_snapshot!(output, @r" ------- stderr ------- Started tracking 1 remote bookmarks. @@ -1510,30 +1512,20 @@ fn test_bookmark_track_untrack_patterns() { [EOF] "); - // Track local bookmark + // Track/untrack new bookmark that doesn't exist at remote work_dir.run_jj(["bookmark", "create", "main"]).success(); insta::assert_snapshot!(work_dir.run_jj(["bookmark", "track", "main"]), @r" ------- stderr ------- - error: invalid value 'main' for '...': remote bookmark must be specified in bookmark@remote form - - For more information, try '--help'. - [EOF] - [exit status: 2] - "); - - // Track/untrack new bookmark that doesn't exist at remote - insta::assert_snapshot!(work_dir.run_jj(["bookmark", "track", "main@origin"]), @r" - ------- stderr ------- Started tracking 1 remote bookmarks. [EOF] "); - insta::assert_snapshot!(work_dir.run_jj(["bookmark", "untrack", "main@origin"]), @r" + insta::assert_snapshot!(work_dir.run_jj(["bookmark", "untrack", "main"]), @r" ------- stderr ------- Stopped tracking 1 remote bookmarks. [EOF] "); insta::assert_snapshot!( - work_dir.run_jj(["bookmark", "untrack", "main@origin", "glob:main@o*"]), @r" + work_dir.run_jj(["bookmark", "untrack", "main", "--remote=glob:o*"]), @r" ------- stderr ------- Warning: Remote bookmark not tracked yet: main@origin Nothing changed. @@ -1541,24 +1533,23 @@ fn test_bookmark_track_untrack_patterns() { "); // Track/untrack unknown bookmark - insta::assert_snapshot!(work_dir.run_jj(["bookmark", "track", "glob:maine@*"]), @r" + insta::assert_snapshot!(work_dir.run_jj(["bookmark", "track", "glob:maine*"]), @r" ------- stderr ------- Nothing changed. [EOF] "); insta::assert_snapshot!( - work_dir.run_jj(["bookmark", "untrack", "maine@origin", "glob:maine@o*"]), @r" + work_dir.run_jj(["bookmark", "untrack", "maine", "--remote=glob:o* | unknown"]), @r" ------- stderr ------- - Warning: No matching remote bookmarks for names: maine@origin + Warning: No matching bookmarks for names: maine + Warning: No matching remotes for names: unknown Nothing changed. [EOF] "); // Track already tracked bookmark - work_dir - .run_jj(["bookmark", "track", "feature1@origin"]) - .success(); - let output = work_dir.run_jj(["bookmark", "track", "feature1@origin"]); + work_dir.run_jj(["bookmark", "track", "feature1"]).success(); + let output = work_dir.run_jj(["bookmark", "track", "feature1"]); insta::assert_snapshot!(output, @r" ------- stderr ------- Warning: Remote bookmark already tracked: feature1@origin @@ -1567,7 +1558,7 @@ fn test_bookmark_track_untrack_patterns() { "); // Untrack non-tracking bookmark - let output = work_dir.run_jj(["bookmark", "untrack", "feature2@origin"]); + let output = work_dir.run_jj(["bookmark", "untrack", "feature2"]); insta::assert_snapshot!(output, @r" ------- stderr ------- Warning: Remote bookmark not tracked yet: feature2@origin @@ -1575,9 +1566,16 @@ fn test_bookmark_track_untrack_patterns() { [EOF] "); - // Untrack Git-tracking bookmark + // Track/untrack Git-tracking bookmark work_dir.run_jj(["git", "export"]).success(); - let output = work_dir.run_jj(["bookmark", "untrack", "main@git"]); + let output = work_dir.run_jj(["bookmark", "track", "main", "--remote=git"]); + insta::assert_snapshot!(output, @r" + ------- stderr ------- + Warning: Remote bookmark already tracked: main@git + Nothing changed. + [EOF] + "); + let output = work_dir.run_jj(["bookmark", "untrack", "main", "--remote=git"]); insta::assert_snapshot!(output, @r" ------- stderr ------- Warning: Git-tracking bookmark cannot be untracked: main@git @@ -1594,14 +1592,20 @@ fn test_bookmark_track_untrack_patterns() { [EOF] "); + // Git-tracking remote should not be warned by default + let output = work_dir.run_jj(["bookmark", "track", "main"]); + insta::assert_snapshot!(output, @r" + ------- stderr ------- + Started tracking 1 remote bookmarks. + [EOF] + "); + // Untrack by pattern - let output = work_dir.run_jj(["bookmark", "untrack", "glob:*@*"]); + let output = work_dir.run_jj(["bookmark", "untrack", "~glob:main", "--remote=glob:*"]); insta::assert_snapshot!(output, @r" ------- stderr ------- Warning: Git-tracking bookmark cannot be untracked: feature1@git Warning: Remote bookmark not tracked yet: feature2@origin - Warning: Git-tracking bookmark cannot be untracked: main@git - Warning: Remote bookmark not tracked yet: main@origin Stopped tracking 1 remote bookmarks. [EOF] "); @@ -1612,13 +1616,20 @@ fn test_bookmark_track_untrack_patterns() { feature2@origin: yrnqsqlx 41e7a49d commit main: qpvuntsm e8849ae1 (empty) (no description set) @git: qpvuntsm e8849ae1 (empty) (no description set) + @origin (not created yet) [EOF] "); // Track by pattern - let output = work_dir.run_jj(["bookmark", "track", "glob:feature?@origin"]); + let output = work_dir.run_jj([ + "bookmark", + "track", + "glob:'feature?' | main", + "--remote=~git", + ]); insta::assert_snapshot!(output, @r" ------- stderr ------- + Warning: Remote bookmark already tracked: main@origin Started tracking 2 remote bookmarks. [EOF] "); @@ -1630,6 +1641,90 @@ fn test_bookmark_track_untrack_patterns() { @origin: yrnqsqlx 41e7a49d commit main: qpvuntsm e8849ae1 (empty) (no description set) @git: qpvuntsm e8849ae1 (empty) (no description set) + @origin (not created yet) + [EOF] + "); +} + +#[test] +fn test_bookmark_track_absent() { + let test_env = TestEnvironment::default(); + test_env.run_jj_in(".", ["git", "init", "repo"]).success(); + let work_dir = test_env.work_dir("repo"); + + // Set up remotes + let git_repo1 = { + let git_repo_path = test_env.env_root().join("remote1"); + let git_repo = git::init(git_repo_path); + work_dir + .run_jj(["git", "remote", "add", "remote1", "../remote1"]) + .success(); + git_repo + }; + let _git_repo2 = { + let git_repo_path = test_env.env_root().join("remote2"); + let git_repo = git::init(git_repo_path); + work_dir + .run_jj(["git", "remote", "add", "remote2", "../remote2"]) + .success(); + git_repo + }; + + // Create feature1@remote1 + create_commit_with_refs(&git_repo1, "commit", b"", &["refs/heads/feature1"]); + + let output = work_dir.run_jj(["git", "fetch", "--all-remotes"]); + insta::assert_snapshot!(output, @r" + ------- stderr ------- + bookmark: feature1@remote1 [new] untracked + [EOF] + "); + + // Track feature1: remote2 isn't tracked because there's no local bookmark + insta::assert_snapshot!( + work_dir.run_jj(["bookmark", "track", "feature1", "--remote=glob:*"]), @r" + ------- stderr ------- + Started tracking 1 remote bookmarks. + [EOF] + "); + insta::assert_snapshot!(get_bookmark_output(&work_dir), @r" + feature1: quutswnw 3fb14832 commit + @remote1: quutswnw 3fb14832 commit + [EOF] + "); + + // Track feature1 again: remote2 is now tracked + insta::assert_snapshot!( + work_dir.run_jj(["bookmark", "track", "feature1", "--remote=glob:*"]), @r" + ------- stderr ------- + Warning: Remote bookmark already tracked: feature1@remote1 + Started tracking 1 remote bookmarks. + [EOF] + "); + insta::assert_snapshot!(get_bookmark_output(&work_dir), @r" + feature1: quutswnw 3fb14832 commit + @remote1: quutswnw 3fb14832 commit + @remote2 (not created yet) + [EOF] + "); + + // Track newly-created bookmark: both remotes are tracked + work_dir + .run_jj(["bookmark", "create", "new-feature"]) + .success(); + insta::assert_snapshot!( + work_dir.run_jj(["bookmark", "track", "new-feature", "--remote=glob:*"]), @r" + ------- stderr ------- + Started tracking 2 remote bookmarks. + [EOF] + "); + insta::assert_snapshot!(get_bookmark_output(&work_dir), @r" + feature1: quutswnw 3fb14832 commit + @remote1: quutswnw 3fb14832 commit + @remote2 (not created yet) + new-feature: qpvuntsm e8849ae1 (empty) (no description set) + @remote1 (not created yet) + @remote2 (not created yet) [EOF] "); } @@ -1689,10 +1784,10 @@ fn test_bookmark_list() { .run_jj(["bookmark", "delete", "remote-untrack"]) .success(); local_dir - .run_jj(["bookmark", "track", "absent-tracked@origin"]) + .run_jj(["bookmark", "track", "absent-tracked"]) .success(); local_dir - .run_jj(["bookmark", "untrack", "remote-untrack@origin"]) + .run_jj(["bookmark", "untrack", "remote-untrack"]) .success(); local_dir .run_jj(["bookmark", "set", "--allow-backwards", "remote-unsync"]) @@ -2329,7 +2424,7 @@ fn test_bookmark_list_tracked() { .run_jj(["bookmark", "delete", "remote-untrack"]) .success(); local_dir - .run_jj(["bookmark", "untrack", "remote-untrack@origin"]) + .run_jj(["bookmark", "untrack", "remote-untrack", "--remote=origin"]) .success(); local_dir .run_jj([ @@ -2412,7 +2507,7 @@ fn test_bookmark_list_tracked() { insta::assert_snapshot!(output, @""); local_dir - .run_jj(["bookmark", "untrack", "remote-unsync@upstream"]) + .run_jj(["bookmark", "untrack", "remote-unsync", "--remote=upstream"]) .success(); let output = local_dir.run_jj(["bookmark", "list", "--tracked", "remote-unsync"]); diff --git a/cli/tests/test_commit_template.rs b/cli/tests/test_commit_template.rs index d2071954b..6e95ce609 100644 --- a/cli/tests/test_commit_template.rs +++ b/cli/tests/test_commit_template.rs @@ -656,9 +656,7 @@ fn test_log_bookmarks() { // Track all remote bookmarks, rewrite bookmark1, move bookmark2 forward, // create conflict in bookmark3, add new-bookmark - work_dir - .run_jj(["bookmark", "track", "glob:*@origin"]) - .success(); + work_dir.run_jj(["bookmark", "track", "glob:*"]).success(); work_dir .run_jj(["describe", "bookmark1", "-m", "modified bookmark1 commit"]) .success(); diff --git a/cli/tests/test_git_fetch.rs b/cli/tests/test_git_fetch.rs index 6e8144a83..5714ea169 100644 --- a/cli/tests/test_git_fetch.rs +++ b/cli/tests/test_git_fetch.rs @@ -1950,7 +1950,7 @@ fn test_git_fetch_tracked() { // Now untrack feature1 work_dir - .run_jj(["bookmark", "untrack", "feature1@origin"]) + .run_jj(["bookmark", "untrack", "feature1"]) .success(); // Verify feature1 is untracked @@ -2023,9 +2023,7 @@ fn test_git_fetch_tracked_no_tracked_bookmarks() { work_dir.run_jj(["git", "fetch"]).success(); // Untrack all bookmarks - work_dir - .run_jj(["bookmark", "untrack", "glob:*@origin"]) - .success(); + work_dir.run_jj(["bookmark", "untrack", "glob:*"]).success(); // Fetch with --tracked should indicate nothing changed let output = work_dir.run_jj(["git", "fetch", "--tracked"]); @@ -2072,18 +2070,18 @@ fn test_git_fetch_tracked_multiple_remotes() { // Track different branches from different remotes work_dir - .run_jj(["bookmark", "track", "feature1@origin"]) + .run_jj(["bookmark", "track", "feature1", "--remote=origin"]) .success(); work_dir - .run_jj(["bookmark", "track", "develop@upstream"]) + .run_jj(["bookmark", "track", "develop", "--remote=upstream"]) .success(); // Untrack some branches to test --tracked behavior work_dir - .run_jj(["bookmark", "untrack", "feature2@origin"]) + .run_jj(["bookmark", "untrack", "feature2", "--remote=origin"]) .success(); work_dir - .run_jj(["bookmark", "untrack", "hotfix@upstream"]) + .run_jj(["bookmark", "untrack", "hotfix", "--remote=upstream"]) .success(); insta::assert_snapshot!(get_bookmark_output(&work_dir), @r" diff --git a/cli/tests/test_git_push.rs b/cli/tests/test_git_push.rs index 5ba1f8f68..74722fe30 100644 --- a/cli/tests/test_git_push.rs +++ b/cli/tests/test_git_push.rs @@ -276,7 +276,7 @@ fn test_git_push_other_remote_has_bookmark() { // // TODO: Saner test? work_dir - .run_jj(["bookmark", "track", "bookmark1@other"]) + .run_jj(["bookmark", "track", "bookmark1", "--remote=other"]) .success(); let output = work_dir.run_jj(["git", "push", "--remote=other"]); insta::assert_snapshot!(output, @r" @@ -624,7 +624,7 @@ fn test_git_push_locally_created_and_rewritten() { "); // Absent-tracked bookmark can be pushed without --allow-new work_dir - .run_jj(["bookmark", "track", "my@origin"]) + .run_jj(["bookmark", "track", "my", "--remote=origin"]) .success(); let output = work_dir.run_jj(["git", "push"]); insta::assert_snapshot!(output, @r" @@ -1103,7 +1103,7 @@ fn test_git_push_changes_with_name_deleted_tracked() { // OK to push to a different remote once the bookmark is no longer tracked on // `origin` work_dir - .run_jj(["bookmark", "untrack", "b1@origin"]) + .run_jj(["bookmark", "untrack", "b1", "--remote=origin"]) .success(); let output = work_dir .run_jj(["bookmark", "list", "--all", "b1"]) @@ -1150,9 +1150,7 @@ fn test_git_push_changes_with_name_untracked_or_forgotten() { work_dir .run_jj(["git", "push", "--named", "b1=@"]) .success(); - work_dir - .run_jj(["bookmark", "untrack", "b1@origin"]) - .success(); + work_dir.run_jj(["bookmark", "untrack", "b1"]).success(); work_dir.run_jj(["bookmark", "delete", "b1"]).success(); let output = work_dir @@ -1799,7 +1797,7 @@ fn test_git_push_deleted_untracked() { .run_jj(["bookmark", "delete", "bookmark1"]) .success(); work_dir - .run_jj(["bookmark", "untrack", "bookmark1@origin"]) + .run_jj(["bookmark", "untrack", "bookmark1"]) .success(); let output = work_dir.run_jj(["git", "push", "--deleted"]); insta::assert_snapshot!(output, @r" @@ -1834,7 +1832,7 @@ fn test_git_push_tracked_vs_all() { .run_jj(["bookmark", "delete", "bookmark2"]) .success(); work_dir - .run_jj(["bookmark", "untrack", "bookmark1@origin"]) + .run_jj(["bookmark", "untrack", "bookmark1"]) .success(); work_dir .run_jj(["bookmark", "create", "-r@", "bookmark3"]) @@ -1870,7 +1868,7 @@ fn test_git_push_tracked_vs_all() { // Untrack the last remaining tracked bookmark. work_dir - .run_jj(["bookmark", "untrack", "bookmark2@origin"]) + .run_jj(["bookmark", "untrack", "bookmark2"]) .success(); insta::assert_snapshot!(get_bookmark_output(&work_dir), @r" bookmark1: vruxwmqv d7607a25 (empty) moved bookmark1 @@ -1902,8 +1900,8 @@ fn test_git_push_tracked_vs_all() { // - Whatever we do should be consistent with what `jj bookmark list` does; it // currently does *not* list bookmarks like bookmark2 as "about to be // deleted", as can be seen above. - // - We could consider showing some hint on `jj bookmark untrack - // bookmark2@origin` instead of showing an error here. + // - We could consider showing some hint on `jj bookmark untrack bookmark2 + // --remote=origin` instead of showing an error here. let output = work_dir.run_jj(["git", "push", "--all"]); insta::assert_snapshot!(output, @r" ------- stderr ------- @@ -1928,7 +1926,7 @@ fn test_git_push_moved_forward_untracked() { .run_jj(["bookmark", "set", "bookmark1", "-r@"]) .success(); work_dir - .run_jj(["bookmark", "untrack", "bookmark1@origin"]) + .run_jj(["bookmark", "untrack", "bookmark1"]) .success(); let output = work_dir.run_jj(["git", "push"]); insta::assert_snapshot!(output, @r" @@ -1953,7 +1951,7 @@ fn test_git_push_moved_sideways_untracked() { .run_jj(["bookmark", "set", "--allow-backwards", "bookmark1", "-r@"]) .success(); work_dir - .run_jj(["bookmark", "untrack", "bookmark1@origin"]) + .run_jj(["bookmark", "untrack", "bookmark1"]) .success(); let output = work_dir.run_jj(["git", "push"]); insta::assert_snapshot!(output, @r" diff --git a/cli/tests/test_log_command.rs b/cli/tests/test_log_command.rs index b97feb82b..84fc2ce2a 100644 --- a/cli/tests/test_log_command.rs +++ b/cli/tests/test_log_command.rs @@ -1800,9 +1800,7 @@ fn test_log_anonymize() { .run_jj_in(".", ["git", "clone", origin_git_repo, "local"]) .success(); let work_dir = test_env.work_dir("local"); - work_dir - .run_jj(["bookmark", "track", "b1@origin", "b2@origin"]) - .success(); + work_dir.run_jj(["bookmark", "track", "b1 | b2"]).success(); work_dir.run_jj(["new", "b1"]).success(); work_dir.run_jj(["bookmark", "move", "b1", "-t@"]).success(); diff --git a/cli/tests/test_op_revert_command.rs b/cli/tests/test_op_revert_command.rs index 9d3a99a4c..d31ee89ed 100644 --- a/cli/tests/test_op_revert_command.rs +++ b/cli/tests/test_op_revert_command.rs @@ -423,7 +423,7 @@ fn test_bookmark_track_untrack_revert() { // Track/untrack can be reverted so long as states can be trivially merged. work_dir - .run_jj(["bookmark", "untrack", "feature1@origin", "feature2@origin"]) + .run_jj(["bookmark", "untrack", "feature1 | feature2"]) .success(); insta::assert_snapshot!(get_bookmark_output(&work_dir), @r" feature1: qpvuntsm bab5b5ef (empty) commit @@ -449,9 +449,7 @@ fn test_bookmark_track_untrack_revert() { [EOF] "); - work_dir - .run_jj(["bookmark", "track", "feature1@origin"]) - .success(); + work_dir.run_jj(["bookmark", "track", "feature1"]).success(); insta::assert_snapshot!(get_bookmark_output(&work_dir), @r" feature1: qpvuntsm bab5b5ef (empty) commit @origin: qpvuntsm bab5b5ef (empty) commit diff --git a/cli/tests/test_operations.rs b/cli/tests/test_operations.rs index 9a3b0e74d..0916d3771 100644 --- a/cli/tests/test_operations.rs +++ b/cli/tests/test_operations.rs @@ -1139,15 +1139,15 @@ fn test_op_diff() { .success(); work_dir.run_jj(["git", "fetch"]).success(); work_dir - .run_jj(["bookmark", "track", "bookmark-1@origin"]) + .run_jj(["bookmark", "track", "bookmark-1"]) .success(); // Overview of op log. let output = work_dir.run_jj(["op", "log"]); insta::assert_snapshot!(output, @r" - @ 64f6f2454329 test-username@host.example.com 2001-02-03 04:05:10.000 +07:00 - 2001-02-03 04:05:10.000 +07:00 + @ 14a49257b1cb test-username@host.example.com 2001-02-03 04:05:10.000 +07:00 - 2001-02-03 04:05:10.000 +07:00 │ track remote bookmark bookmark-1@origin - │ args: jj bookmark track bookmark-1@origin + │ args: jj bookmark track bookmark-1 ○ 93de354b21ad test-username@host.example.com 2001-02-03 04:05:09.000 +07:00 - 2001-02-03 04:05:09.000 +07:00 │ fetch from git remote(s) origin │ args: jj git fetch @@ -1169,8 +1169,8 @@ fn test_op_diff() { "); let output = work_dir.run_jj(["op", "diff", "--from", "@", "--to", "@"]); insta::assert_snapshot!(output, @r" - From operation: 64f6f2454329 (2001-02-03 08:05:10) track remote bookmark bookmark-1@origin - To operation: 64f6f2454329 (2001-02-03 08:05:10) track remote bookmark bookmark-1@origin + From operation: 14a49257b1cb (2001-02-03 08:05:10) track remote bookmark bookmark-1@origin + To operation: 14a49257b1cb (2001-02-03 08:05:10) track remote bookmark bookmark-1@origin [EOF] "); @@ -1180,7 +1180,7 @@ fn test_op_diff() { let output = work_dir.run_jj(["op", "diff", "--from", "@-", "--to", "@"]); insta::assert_snapshot!(output, @r" From operation: 93de354b21ad (2001-02-03 08:05:09) fetch from git remote(s) origin - To operation: 64f6f2454329 (2001-02-03 08:05:10) track remote bookmark bookmark-1@origin + To operation: 14a49257b1cb (2001-02-03 08:05:10) track remote bookmark bookmark-1@origin Changed local bookmarks: bookmark-1: @@ -1200,7 +1200,7 @@ fn test_op_diff() { let output = work_dir.run_jj(["op", "diff", "--from", "0000000"]); insta::assert_snapshot!(output, @r" From operation: 000000000000 root() - To operation: 64f6f2454329 (2001-02-03 08:05:10) track remote bookmark bookmark-1@origin + To operation: 14a49257b1cb (2001-02-03 08:05:10) track remote bookmark bookmark-1@origin Changed commits: ○ + rnnslrkn 4ff62539 bookmark-2@origin | Commit 2 @@ -1233,7 +1233,7 @@ fn test_op_diff() { // Diff from latest operation to root operation let output = work_dir.run_jj(["op", "diff", "--to", "0000000"]); insta::assert_snapshot!(output, @r" - From operation: 64f6f2454329 (2001-02-03 08:05:10) track remote bookmark bookmark-1@origin + From operation: 14a49257b1cb (2001-02-03 08:05:10) track remote bookmark bookmark-1@origin To operation: 000000000000 root() Changed commits: @@ -1290,12 +1290,12 @@ fn test_op_diff() { "); let output = work_dir.run_jj(["op", "log"]); insta::assert_snapshot!(output, @r" - @ 4ee6d5cabe2e test-username@host.example.com 2001-02-03 04:05:19.000 +07:00 - 2001-02-03 04:05:19.000 +07:00 + @ 8aa8ee21be82 test-username@host.example.com 2001-02-03 04:05:19.000 +07:00 - 2001-02-03 04:05:19.000 +07:00 ├─╮ reconcile divergent operations │ │ args: jj log - ○ │ 64f6f2454329 test-username@host.example.com 2001-02-03 04:05:10.000 +07:00 - 2001-02-03 04:05:10.000 +07:00 + ○ │ 14a49257b1cb test-username@host.example.com 2001-02-03 04:05:10.000 +07:00 - 2001-02-03 04:05:10.000 +07:00 │ │ track remote bookmark bookmark-1@origin - │ │ args: jj bookmark track bookmark-1@origin + │ │ args: jj bookmark track bookmark-1 │ ○ e932e147b07d test-username@host.example.com 2001-02-03 04:05:18.000 +07:00 - 2001-02-03 04:05:18.000 +07:00 ├─╯ point bookmark bookmark-1 to commit 4ff6253913375c6ebdddd8423c11df3b3f17e331 │ args: jj bookmark set bookmark-1 -r bookmark-2@origin --at-op @- @@ -1318,8 +1318,8 @@ fn test_op_diff() { // Diff between the first parent of the merge operation and the merge operation. let output = work_dir.run_jj(["op", "diff", "--from", first_parent_id, "--to", op_id]); insta::assert_snapshot!(output, @r" - From operation: 64f6f2454329 (2001-02-03 08:05:10) track remote bookmark bookmark-1@origin - To operation: 4ee6d5cabe2e (2001-02-03 08:05:19) reconcile divergent operations + From operation: 14a49257b1cb (2001-02-03 08:05:10) track remote bookmark bookmark-1@origin + To operation: 8aa8ee21be82 (2001-02-03 08:05:19) reconcile divergent operations Changed local bookmarks: bookmark-1: @@ -1334,7 +1334,7 @@ fn test_op_diff() { let output = work_dir.run_jj(["op", "diff", "--from", second_parent_id, "--to", op_id]); insta::assert_snapshot!(output, @r" From operation: e932e147b07d (2001-02-03 08:05:18) point bookmark bookmark-1 to commit 4ff6253913375c6ebdddd8423c11df3b3f17e331 - To operation: 4ee6d5cabe2e (2001-02-03 08:05:19) reconcile divergent operations + To operation: 8aa8ee21be82 (2001-02-03 08:05:19) reconcile divergent operations Changed local bookmarks: bookmark-1: @@ -1362,8 +1362,8 @@ fn test_op_diff() { "); let output = work_dir.run_jj(["op", "diff"]); insta::assert_snapshot!(output, @r" - From operation: 4ee6d5cabe2e (2001-02-03 08:05:19) reconcile divergent operations - To operation: 37661c38b5a1 (2001-02-03 08:05:23) fetch from git remote(s) origin + From operation: 8aa8ee21be82 (2001-02-03 08:05:19) reconcile divergent operations + To operation: 26d9ccc41b21 (2001-02-03 08:05:23) fetch from git remote(s) origin Changed commits: ○ + kulxwnxm e1a239a5 bookmark-2@origin | Commit 5 @@ -1405,8 +1405,8 @@ fn test_op_diff() { "); let output = work_dir.run_jj(["op", "diff"]); insta::assert_snapshot!(output, @r" - From operation: 37661c38b5a1 (2001-02-03 08:05:23) fetch from git remote(s) origin - To operation: 83bf9eca7d31 (2001-02-03 08:05:25) create bookmark bookmark-2 pointing to commit e1a239a57eb15cefc5910198befbbbe2b43c47af + From operation: 26d9ccc41b21 (2001-02-03 08:05:23) fetch from git remote(s) origin + To operation: 68ab6999295f (2001-02-03 08:05:25) create bookmark bookmark-2 pointing to commit e1a239a57eb15cefc5910198befbbbe2b43c47af Changed local bookmarks: bookmark-2: @@ -1416,7 +1416,7 @@ fn test_op_diff() { "); // Test tracking of bookmark. - let output = work_dir.run_jj(["bookmark", "track", "bookmark-2@origin"]); + let output = work_dir.run_jj(["bookmark", "track", "bookmark-2"]); insta::assert_snapshot!(output, @r" ------- stderr ------- Started tracking 1 remote bookmarks. @@ -1424,8 +1424,8 @@ fn test_op_diff() { "); let output = work_dir.run_jj(["op", "diff"]); insta::assert_snapshot!(output, @r" - From operation: 83bf9eca7d31 (2001-02-03 08:05:25) create bookmark bookmark-2 pointing to commit e1a239a57eb15cefc5910198befbbbe2b43c47af - To operation: 818db089870a (2001-02-03 08:05:27) track remote bookmark bookmark-2@origin + From operation: 68ab6999295f (2001-02-03 08:05:25) create bookmark bookmark-2 pointing to commit e1a239a57eb15cefc5910198befbbbe2b43c47af + To operation: dfa9381f7159 (2001-02-03 08:05:27) track remote bookmark bookmark-2@origin Changed remote bookmarks: bookmark-2@origin: @@ -1436,7 +1436,7 @@ fn test_op_diff() { // Test creation of new commit. // Test tracking of bookmark. - let output = work_dir.run_jj(["bookmark", "track", "bookmark-2@origin"]); + let output = work_dir.run_jj(["bookmark", "track", "bookmark-2"]); insta::assert_snapshot!(output, @r" ------- stderr ------- Warning: Remote bookmark already tracked: bookmark-2@origin @@ -1445,8 +1445,8 @@ fn test_op_diff() { "); let output = work_dir.run_jj(["op", "diff"]); insta::assert_snapshot!(output, @r" - From operation: 83bf9eca7d31 (2001-02-03 08:05:25) create bookmark bookmark-2 pointing to commit e1a239a57eb15cefc5910198befbbbe2b43c47af - To operation: 818db089870a (2001-02-03 08:05:27) track remote bookmark bookmark-2@origin + From operation: 68ab6999295f (2001-02-03 08:05:25) create bookmark bookmark-2 pointing to commit e1a239a57eb15cefc5910198befbbbe2b43c47af + To operation: dfa9381f7159 (2001-02-03 08:05:27) track remote bookmark bookmark-2@origin Changed remote bookmarks: bookmark-2@origin: @@ -1466,8 +1466,8 @@ fn test_op_diff() { "); let output = work_dir.run_jj(["op", "diff"]); insta::assert_snapshot!(output, @r" - From operation: 818db089870a (2001-02-03 08:05:27) track remote bookmark bookmark-2@origin - To operation: 263f1b7d2e97 (2001-02-03 08:05:31) new empty commit + From operation: dfa9381f7159 (2001-02-03 08:05:27) track remote bookmark bookmark-2@origin + To operation: 8cdaab259ed6 (2001-02-03 08:05:31) new empty commit Changed commits: ○ + xlzxqlsl 731ab199 (empty) new commit @@ -1488,8 +1488,8 @@ fn test_op_diff() { "); let output = work_dir.run_jj(["op", "diff"]); insta::assert_snapshot!(output, @r" - From operation: 263f1b7d2e97 (2001-02-03 08:05:31) new empty commit - To operation: a90be14f7026 (2001-02-03 08:05:33) point bookmark bookmark-1 to commit 731ab19950fc6fc1199b9ea73cb8b9016f22e8f3 + From operation: 8cdaab259ed6 (2001-02-03 08:05:31) new empty commit + To operation: ea9f7f618485 (2001-02-03 08:05:33) point bookmark bookmark-1 to commit 731ab19950fc6fc1199b9ea73cb8b9016f22e8f3 Changed local bookmarks: bookmark-1: @@ -1508,8 +1508,8 @@ fn test_op_diff() { "); let output = work_dir.run_jj(["op", "diff"]); insta::assert_snapshot!(output, @r" - From operation: a90be14f7026 (2001-02-03 08:05:33) point bookmark bookmark-1 to commit 731ab19950fc6fc1199b9ea73cb8b9016f22e8f3 - To operation: 1b2b83317596 (2001-02-03 08:05:35) delete bookmark bookmark-2 + From operation: ea9f7f618485 (2001-02-03 08:05:33) point bookmark bookmark-1 to commit 731ab19950fc6fc1199b9ea73cb8b9016f22e8f3 + To operation: fd2ddf76493d (2001-02-03 08:05:35) delete bookmark bookmark-2 Changed local bookmarks: bookmark-2: @@ -1529,8 +1529,8 @@ fn test_op_diff() { "); let output = work_dir.run_jj(["op", "diff"]); insta::assert_snapshot!(output, @r" - From operation: 1b2b83317596 (2001-02-03 08:05:35) delete bookmark bookmark-2 - To operation: b85f801e5384 (2001-02-03 08:05:37) push all tracked bookmarks to git remote origin + From operation: fd2ddf76493d (2001-02-03 08:05:35) delete bookmark bookmark-2 + To operation: 6bfdecc01c75 (2001-02-03 08:05:37) push all tracked bookmarks to git remote origin Changed remote bookmarks: bookmark-1@origin: @@ -2284,15 +2284,15 @@ fn test_op_show() { .success(); work_dir.run_jj(["git", "fetch"]).success(); work_dir - .run_jj(["bookmark", "track", "bookmark-1@origin"]) + .run_jj(["bookmark", "track", "bookmark-1"]) .success(); // Overview of op log. let output = work_dir.run_jj(["op", "log"]); insta::assert_snapshot!(output, @r" - @ 64f6f2454329 test-username@host.example.com 2001-02-03 04:05:10.000 +07:00 - 2001-02-03 04:05:10.000 +07:00 + @ 14a49257b1cb test-username@host.example.com 2001-02-03 04:05:10.000 +07:00 - 2001-02-03 04:05:10.000 +07:00 │ track remote bookmark bookmark-1@origin - │ args: jj bookmark track bookmark-1@origin + │ args: jj bookmark track bookmark-1 ○ 93de354b21ad test-username@host.example.com 2001-02-03 04:05:09.000 +07:00 - 2001-02-03 04:05:09.000 +07:00 │ fetch from git remote(s) origin │ args: jj git fetch @@ -2315,9 +2315,9 @@ fn test_op_show() { // Showing the latest operation. let output = work_dir.run_jj(["op", "show", "@"]); insta::assert_snapshot!(output, @r" - 64f6f2454329 test-username@host.example.com 2001-02-03 04:05:10.000 +07:00 - 2001-02-03 04:05:10.000 +07:00 + 14a49257b1cb test-username@host.example.com 2001-02-03 04:05:10.000 +07:00 - 2001-02-03 04:05:10.000 +07:00 track remote bookmark bookmark-1@origin - args: jj bookmark track bookmark-1@origin + args: jj bookmark track bookmark-1 Changed local bookmarks: bookmark-1: @@ -2386,7 +2386,7 @@ fn test_op_show() { // Showing a merge operation is empty. let output = work_dir.run_jj(["op", "show"]); insta::assert_snapshot!(output, @r" - f7f71a8bc2f4 test-username@host.example.com 2001-02-03 04:05:17.000 +07:00 - 2001-02-03 04:05:17.000 +07:00 + d179a8a7f8bf test-username@host.example.com 2001-02-03 04:05:17.000 +07:00 - 2001-02-03 04:05:17.000 +07:00 reconcile divergent operations args: jj log [EOF] @@ -2405,7 +2405,7 @@ fn test_op_show() { "); let output = work_dir.run_jj(["op", "show"]); insta::assert_snapshot!(output, @r" - a32821470ddb test-username@host.example.com 2001-02-03 04:05:19.000 +07:00 - 2001-02-03 04:05:19.000 +07:00 + dc9a130455e8 test-username@host.example.com 2001-02-03 04:05:19.000 +07:00 - 2001-02-03 04:05:19.000 +07:00 fetch from git remote(s) origin args: jj git fetch @@ -2449,7 +2449,7 @@ fn test_op_show() { "); let output = work_dir.run_jj(["op", "show"]); insta::assert_snapshot!(output, @r" - 2ce7ebded2de test-username@host.example.com 2001-02-03 04:05:21.000 +07:00 - 2001-02-03 04:05:21.000 +07:00 + 2e0e79579bb2 test-username@host.example.com 2001-02-03 04:05:21.000 +07:00 - 2001-02-03 04:05:21.000 +07:00 create bookmark bookmark-2 pointing to commit e1a239a57eb15cefc5910198befbbbe2b43c47af args: jj bookmark create bookmark-2 -r bookmark-2@origin @@ -2461,7 +2461,7 @@ fn test_op_show() { "); // Test tracking of a bookmark. - let output = work_dir.run_jj(["bookmark", "track", "bookmark-2@origin"]); + let output = work_dir.run_jj(["bookmark", "track", "bookmark-2"]); insta::assert_snapshot!(output, @r" ------- stderr ------- Started tracking 1 remote bookmarks. @@ -2469,9 +2469,9 @@ fn test_op_show() { "); let output = work_dir.run_jj(["op", "show"]); insta::assert_snapshot!(output, @r" - 9cc95f35ba27 test-username@host.example.com 2001-02-03 04:05:23.000 +07:00 - 2001-02-03 04:05:23.000 +07:00 + 75265616f1b2 test-username@host.example.com 2001-02-03 04:05:23.000 +07:00 - 2001-02-03 04:05:23.000 +07:00 track remote bookmark bookmark-2@origin - args: jj bookmark track bookmark-2@origin + args: jj bookmark track bookmark-2 Changed remote bookmarks: bookmark-2@origin: @@ -2481,7 +2481,7 @@ fn test_op_show() { "); // Test creation of new commit. - let output = work_dir.run_jj(["bookmark", "track", "bookmark-2@origin"]); + let output = work_dir.run_jj(["bookmark", "track", "bookmark-2"]); insta::assert_snapshot!(output, @r" ------- stderr ------- Warning: Remote bookmark already tracked: bookmark-2@origin @@ -2490,9 +2490,9 @@ fn test_op_show() { "); let output = work_dir.run_jj(["op", "show"]); insta::assert_snapshot!(output, @r" - 9cc95f35ba27 test-username@host.example.com 2001-02-03 04:05:23.000 +07:00 - 2001-02-03 04:05:23.000 +07:00 + 75265616f1b2 test-username@host.example.com 2001-02-03 04:05:23.000 +07:00 - 2001-02-03 04:05:23.000 +07:00 track remote bookmark bookmark-2@origin - args: jj bookmark track bookmark-2@origin + args: jj bookmark track bookmark-2 Changed remote bookmarks: bookmark-2@origin: @@ -2512,7 +2512,7 @@ fn test_op_show() { "); let output = work_dir.run_jj(["op", "show"]); insta::assert_snapshot!(output, @r" - 8727dbd86fa3 test-username@host.example.com 2001-02-03 04:05:27.000 +07:00 - 2001-02-03 04:05:27.000 +07:00 + 3117c5ac4af3 test-username@host.example.com 2001-02-03 04:05:27.000 +07:00 - 2001-02-03 04:05:27.000 +07:00 new empty commit args: jj new bookmark-1@origin -m 'new commit' @@ -2535,7 +2535,7 @@ fn test_op_show() { "); let output = work_dir.run_jj(["op", "show"]); insta::assert_snapshot!(output, @r" - f5d053abd6be test-username@host.example.com 2001-02-03 04:05:29.000 +07:00 - 2001-02-03 04:05:29.000 +07:00 + 2e179db04ef9 test-username@host.example.com 2001-02-03 04:05:29.000 +07:00 - 2001-02-03 04:05:29.000 +07:00 point bookmark bookmark-1 to commit 8f340dd76dc637e4deac17f30056eef7d8eaf682 args: jj bookmark set bookmark-1 -r @ @@ -2556,7 +2556,7 @@ fn test_op_show() { "); let output = work_dir.run_jj(["op", "show"]); insta::assert_snapshot!(output, @r" - 97af2adb0e1f test-username@host.example.com 2001-02-03 04:05:31.000 +07:00 - 2001-02-03 04:05:31.000 +07:00 + 7f6cf80e50d5 test-username@host.example.com 2001-02-03 04:05:31.000 +07:00 - 2001-02-03 04:05:31.000 +07:00 delete bookmark bookmark-2 args: jj bookmark delete bookmark-2 @@ -2578,7 +2578,7 @@ fn test_op_show() { "); let output = work_dir.run_jj(["op", "show"]); insta::assert_snapshot!(output, @r" - e2345a3aa1b3 test-username@host.example.com 2001-02-03 04:05:33.000 +07:00 - 2001-02-03 04:05:33.000 +07:00 + 15c5b97a8e12 test-username@host.example.com 2001-02-03 04:05:33.000 +07:00 - 2001-02-03 04:05:33.000 +07:00 push all tracked bookmarks to git remote origin args: jj git push --tracked --deleted @@ -2593,9 +2593,9 @@ fn test_op_show() { "); // Showing a given operation, without graph - let output = work_dir.run_jj(["op", "show", "--no-graph", "8727dbd86fa3"]); + let output = work_dir.run_jj(["op", "show", "--no-graph", "3117c5ac4af3"]); insta::assert_snapshot!(output, @r" - 8727dbd86fa3 test-username@host.example.com 2001-02-03 04:05:27.000 +07:00 - 2001-02-03 04:05:27.000 +07:00 + 3117c5ac4af3 test-username@host.example.com 2001-02-03 04:05:27.000 +07:00 - 2001-02-03 04:05:27.000 +07:00 new empty commit args: jj new bookmark-1@origin -m 'new commit' diff --git a/demos/demo_git_compat.sh b/demos/demo_git_compat.sh index 8d9e55bb1..220cc92f2 100755 --- a/demos/demo_git_compat.sh +++ b/demos/demo_git_compat.sh @@ -15,7 +15,7 @@ branch. Other remote branches are only available as remote-tracking bookmarks." run_command "jj bookmark list --all" comment "We can create a local bookmark tracking one of the remote branches we just fetched." -run_command "jj bookmark track octocat-patch-1@origin" +run_command "jj bookmark track octocat-patch-1 --remote=origin" comment "By default, \"jj log\" excludes untracked remote branches to focus on \"our\" commits." diff --git a/docs/bookmarks.md b/docs/bookmarks.md index c371ca1e8..dcb2c6580 100644 --- a/docs/bookmarks.md +++ b/docs/bookmarks.md @@ -71,11 +71,11 @@ If you want to know the internals of bookmark tracking, consult the - A **tracked (remote) bookmark** is defined above. You can make a remote bookmark tracked with the [`jj bookmark track` command](#manually-tracking-a-bookmark), for example. -- A **tracking (local) bookmark** is the local bookmark that `jj` tries to keep in - sync with the tracked remote bookmark. For example, after `jj bookmark track - mybookmark@origin`, there will be a local bookmark `mybookmark` that's tracking the - remote `mybookmark@origin` bookmark. A local bookmark can track a bookmark of the same - name on 0 or more remotes. +- A **tracking (local) bookmark** is the local bookmark that `jj` tries to keep + in sync with the tracked remote bookmark. For example, after `jj bookmark + track mybookmark --remote=origin`, there will be a local bookmark `mybookmark` + that's tracking the remote `mybookmark@origin` bookmark. A local bookmark can + track a bookmark of the same name on 0 or more remotes. The notion of tracked bookmarks serves a similar function to the Git notion of an "upstream branch". Unlike Git, a single local bookmark can be tracking remote @@ -84,9 +84,9 @@ must match. ### Manually tracking a bookmark -To track a bookmark permanently use `jj bookmark track @`. -It will now be imported as a local bookmark until you untrack it or it is deleted -on the remote. +To track a bookmark permanently use `jj bookmark track +--remote=`. It will now be imported as a local bookmark until you +untrack it or it is deleted on the remote. Example: @@ -96,7 +96,7 @@ $ jj bookmark list --all $ # Find the bookmark. $ # [...] $ # Actually track the bookmark. -$ jj bookmark track @ # Example: jj bookmark track my-feature@origin +$ jj bookmark track --remote= # Example: jj bookmark track my-feature --remote=origin $ # From this point on, will be imported when fetching from . $ jj git fetch --remote $ # A local bookmark should have been created or updated while fetching. @@ -117,7 +117,7 @@ $ jj bookmark list --all $ # Find the bookmark we no longer want to track. $ # [...] # # Actually untrack it. -$ jj bookmark untrack @ # Example: jj bookmark untrack stuff@origin +$ jj bookmark untrack --remote= # Example: jj bookmark untrack stuff --remote=origin $ # From this point on, this remote bookmark won't be imported anymore. $ # The local bookmark (e.g. stuff) is unaffected. It may or may not still $ # be tracking bookmarks on other remotes (e.g. stuff@upstream). diff --git a/docs/git-command-table.yml b/docs/git-command-table.yml index 913960401..ce6e15d59 100644 --- a/docs/git-command-table.yml +++ b/docs/git-command-table.yml @@ -12,8 +12,8 @@ `jj git clone [--remote ]` Notes: There is no support for cloning non-Git repos yet. -# TODO: Mention that you might need to do a `jj bookmark track branch@remote` to see the -# bookmark in `jj log`. +# TODO: Mention that you might need to do a `jj bookmark track branch` to see +# the bookmark in `jj log`. - Use case: Update the local repo with all bookmarks/branches from a remote Git command: > `git fetch []` diff --git a/docs/github.md b/docs/github.md index 1216f72f4..528d974cb 100644 --- a/docs/github.md +++ b/docs/github.md @@ -41,7 +41,7 @@ $ jj commit -m 'feat(bar): add support for bar' # on the working-copy commit's *parent* because the working copy itself is empty. $ jj bookmark create bar -r @- # `bar` now contains the previous two commits. # Set the bookmark to be tracked on the remote. -$ jj bookmark track bar@origin +$ jj bookmark track bar # Push the bookmark to GitHub (pushes only `bar`) $ jj git push ``` @@ -76,7 +76,7 @@ $ # Do some more work. $ jj commit -m "Update tutorial" # Create a bookmark on the working-copy commit's parent $ jj bookmark create doc-update -r @- -$ jj bookmark track doc-update@origin +$ jj bookmark track doc-update $ jj git push ``` diff --git a/docs/guides/multiple-remotes.md b/docs/guides/multiple-remotes.md index b16a58f25..4ea29f621 100644 --- a/docs/guides/multiple-remotes.md +++ b/docs/guides/multiple-remotes.md @@ -47,7 +47,7 @@ $ jj config set --repo git.fetch '["upstream", "origin"]' $ jj config set --repo git.push origin # Track both remote bookmarks -$ jj bookmark track main@upstream main@origin +$ jj bookmark track main # The upstream repository defines the trunk $ jj config set --repo 'revset-aliases."trunk()"' main@upstream @@ -86,8 +86,8 @@ $ jj config set --repo git.fetch '["origin"]' $ jj config set --repo git.push origin # Track only the origin bookmark -$ jj bookmark track main@origin -$ jj bookmark untrack main@upstream +$ jj bookmark track main --remote=origin +$ jj bookmark untrack main --remote=upstream # The origin repository defines the trunk $ jj config set --repo 'revset-aliases."trunk()"' main@origin