bookmarks: First step to make target revision a required argument to bookmark create/move/set.

With this change a warning is shown if the user does not explicitly specify the target revision, but the behavior is unchanged (it still defaults to the working copy).
In the future the warning will be turned into an error. In other words, it will be required to specify target revision.

The bulk of the changes here are to prepare tests for the upcoming change, to make the transition easier.

For additional details please see:
* https://github.com/jj-vcs/jj/issues/5374
* https://github.com/jj-vcs/jj/discussions/5363
This commit is contained in:
David Rieber 2025-01-23 16:55:14 -08:00
parent b03350eaa1
commit dd73b5ab7d
43 changed files with 516 additions and 333 deletions

View File

@ -22,6 +22,11 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
### Deprecations
* This release takes the first steps to make target revision required in
`bookmark create`, `bookmark move` and `bookmark set`. Those commands will display
a warning if the user does not specify target revision explicitly. In the near
future those commands will fail if target revision is not specified.
### New features
* `jj undo` now shows a hint when undoing an undo operation that the user may

View File

@ -28,10 +28,13 @@ use crate::ui::Ui;
/// Create a new bookmark
#[derive(clap::Args, Clone, Debug)]
pub struct BookmarkCreateArgs {
// TODO(#5374): Make required in jj 0.32+
/// The bookmark's target revision
//
// The `--to` alias exists for making it easier for the user to switch
// between `bookmark create`, `bookmark move`, and `bookmark set`.
// between `bookmark create`, `bookmark move`, and `bookmark set`. Currently target revision
// defaults to the working copy if not specified, but in the near future it will be required to
// explicitly specify it.
#[arg(
long, short,
visible_alias = "to",
@ -51,6 +54,13 @@ pub fn cmd_bookmark_create(
args: &BookmarkCreateArgs,
) -> Result<(), CommandError> {
let mut workspace_command = command.workspace_helper(ui)?;
if args.revision.is_none() {
writeln!(
ui.warning_default(),
"Target revision was not specified, defaulting to the working copy (-r@). In the near \
future it will be required to explicitly specify target revision."
)?;
}
let target_commit = workspace_command
.resolve_single_rev(ui, args.revision.as_ref().unwrap_or(&RevisionArg::AT))?;
let view = workspace_command.repo().view();
@ -90,10 +100,6 @@ pub fn cmd_bookmark_create(
tx.write_commit_summary(formatter.as_mut(), &target_commit)?;
writeln!(formatter)?;
}
if bookmark_names.len() > 1 && args.revision.is_none() {
writeln!(ui.hint_default(), "Use -r to specify the target revision.")?;
}
tx.finish(
ui,
format!(

View File

@ -54,16 +54,17 @@ pub struct BookmarkMoveArgs {
)]
from: Vec<RevisionArg>,
// TODO(#5374): Make required in jj 0.32+
/// Move bookmarks to this revision
// We intentionally do not support the short `-t` for `--to` since we don't
// support `-f` for `--from`.
// support `-f` for `--from`. Currently this defaults to the working copy, but in the near
// future it will be required to explicitly specify it.
#[arg(
long,
default_value = "@",
value_name = "REVSET",
add = ArgValueCandidates::new(complete::all_revisions),
)]
to: RevisionArg,
to: Option<RevisionArg>,
/// Allow moving bookmarks backwards or sideways
#[arg(long, short = 'B')]
@ -91,8 +92,15 @@ pub fn cmd_bookmark_move(
) -> Result<(), CommandError> {
let mut workspace_command = command.workspace_helper(ui)?;
let repo = workspace_command.repo().clone();
let target_commit = workspace_command.resolve_single_rev(ui, &args.to)?;
if args.to.is_none() {
writeln!(
ui.warning_default(),
"Target revision was not specified, defaulting to the working copy (--to=@). In the \
near future it will be required to explicitly specify it."
)?;
}
let target_commit =
workspace_command.resolve_single_rev(ui, args.to.as_ref().unwrap_or(&RevisionArg::AT))?;
let matched_bookmarks = {
let is_source_ref: Box<dyn Fn(&RefTarget) -> _> = if !args.from.is_empty() {
let is_source_commit = workspace_command

View File

@ -29,7 +29,11 @@ use crate::ui::Ui;
/// Create or update a bookmark to point to a certain commit
#[derive(clap::Args, Clone, Debug)]
pub struct BookmarkSetArgs {
// TODO(#5374): Make required in jj 0.32+
/// The bookmark's target revision
//
// Currently target revision defaults to the working copy if not specified, but in the near
// future it will be required to explicitly specify it.
#[arg(
long, short,
visible_alias = "to",
@ -57,6 +61,13 @@ pub fn cmd_bookmark_set(
args: &BookmarkSetArgs,
) -> Result<(), CommandError> {
let mut workspace_command = command.workspace_helper(ui)?;
if args.revision.is_none() {
writeln!(
ui.warning_default(),
"Target revision was not specified, defaulting to the working copy (--revision=@). In \
the near future it will be required to explicitly specify target revision."
)?;
}
let target_commit = workspace_command
.resolve_single_rev(ui, args.revision.as_ref().unwrap_or(&RevisionArg::AT))?;
let repo = workspace_command.repo().as_ref();

View File

@ -421,8 +421,6 @@ $ jj bookmark move --from 'heads(::@- & bookmarks())' --to @-
* `--from <REVSETS>` — Move bookmarks from the given revisions
* `--to <REVSET>` — Move bookmarks to this revision
Default value: `@`
* `-B`, `--allow-backwards` — Allow moving bookmarks backwards or sideways

View File

@ -25,7 +25,7 @@ fn create_commit(test_env: &TestEnvironment, repo_path: &Path, name: &str, paren
test_env.jj_cmd_ok(repo_path, &args);
}
std::fs::write(repo_path.join(name), format!("{name}\n")).unwrap();
test_env.jj_cmd_ok(repo_path, &["bookmark", "create", name]);
test_env.jj_cmd_ok(repo_path, &["bookmark", "create", name, "-r", "@"]);
}
#[test]

View File

@ -114,7 +114,10 @@ fn test_advance_bookmarks_at_minus(make_commit: CommitFn) {
let workspace_path = test_env.env_root().join("repo");
set_advance_bookmarks(&test_env, true);
test_env.jj_cmd_ok(&workspace_path, &["bookmark", "create", "test_bookmark"]);
test_env.jj_cmd_ok(
&workspace_path,
&["bookmark", "create", "test_bookmark", "-r", "@"],
);
insta::allow_duplicates! {
insta::assert_snapshot!(get_log_output_with_bookmarks(&test_env, &workspace_path), @r###"
@ -134,7 +137,10 @@ fn test_advance_bookmarks_at_minus(make_commit: CommitFn) {
// Create a second bookmark pointing to @. On the next commit, only the first
// bookmark, which points to @-, will advance.
test_env.jj_cmd_ok(&workspace_path, &["bookmark", "create", "test_bookmark2"]);
test_env.jj_cmd_ok(
&workspace_path,
&["bookmark", "create", "test_bookmark2", "-r", "@"],
);
make_commit(&test_env, &workspace_path, "second");
insta::allow_duplicates! {
insta::assert_snapshot!(get_log_output_with_bookmarks(&test_env, &workspace_path), @r###"

View File

@ -25,7 +25,10 @@ fn test_alias_basic() {
let repo_path = test_env.env_root().join("repo");
test_env.add_config(r#"aliases.bk = ["log", "-r", "@", "-T", "bookmarks"]"#);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "my-bookmark"]);
test_env.jj_cmd_ok(
&repo_path,
&["bookmark", "create", "my-bookmark", "-r", "@"],
);
let stdout = test_env.jj_cmd_success(&repo_path, &["bk"]);
insta::assert_snapshot!(stdout, @r###"
@ my-bookmark

View File

@ -33,7 +33,7 @@ fn create_commit(
for (name, contents) in files {
std::fs::write(repo_path.join(name), contents).unwrap();
}
test_env.jj_cmd_ok(repo_path, &["bookmark", "create", name]);
test_env.jj_cmd_ok(repo_path, &["bookmark", "create", "-r@", name]);
}
#[test]

View File

@ -46,24 +46,20 @@ fn test_bookmark_multiple_names() {
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
let repo_path = test_env.env_root().join("repo");
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "foo", "bar"]);
let (stdout, stderr) =
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "foo", "bar"]);
insta::assert_snapshot!(stdout, @"");
insta::assert_snapshot!(stderr, @r###"
Created 2 bookmarks pointing to qpvuntsm 230dd059 bar foo | (empty) (no description set)
Hint: Use -r to specify the target revision.
"###);
insta::assert_snapshot!(stderr, @"Created 2 bookmarks pointing to qpvuntsm 230dd059 bar foo | (empty) (no description set)");
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
@ bar foo 230dd059e1b0
000000000000
"###);
test_env.jj_cmd_ok(&repo_path, &["new"]);
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["bookmark", "set", "foo", "bar"]);
let (stdout, stderr) =
test_env.jj_cmd_ok(&repo_path, &["bookmark", "set", "foo", "bar", "--to=@"]);
insta::assert_snapshot!(stdout, @"");
insta::assert_snapshot!(stderr, @r###"
Moved 2 bookmarks to zsuskuln 8bb159bc bar foo | (empty) (no description set)
Hint: Use -r to specify the target revision.
"###);
insta::assert_snapshot!(stderr, @"Moved 2 bookmarks to zsuskuln 8bb159bc bar foo | (empty) (no description set)");
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
@ bar foo 8bb159bc30a9
230dd059e1b0
@ -133,7 +129,7 @@ fn test_bookmark_empty_name() {
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
let repo_path = test_env.env_root().join("repo");
let stderr = test_env.jj_cmd_cli_error(&repo_path, &["bookmark", "create", ""]);
let stderr = test_env.jj_cmd_cli_error(&repo_path, &["bookmark", "create", "-r@", ""]);
insta::assert_snapshot!(stderr, @r###"
error: a value is required for '<NAMES>...' but none was supplied
@ -162,25 +158,26 @@ fn test_bookmark_move() {
&["git", "remote", "add", "origin", "../git-repo"],
);
let stderr = test_env.jj_cmd_failure(&repo_path, &["bookmark", "move", "foo"]);
let stderr = test_env.jj_cmd_failure(&repo_path, &["bookmark", "move", "foo", "--to=@"]);
insta::assert_snapshot!(stderr, @r###"
Error: No such bookmark: foo
"###);
let (_stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["bookmark", "set", "foo"]);
let (_stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["bookmark", "set", "foo", "--to=@"]);
insta::assert_snapshot!(stderr, @r###"
Created 1 bookmarks pointing to qpvuntsm 230dd059 foo | (empty) (no description set)
Hint: Consider using `jj bookmark move` if your intention was to move existing bookmarks.
"###);
test_env.jj_cmd_ok(&repo_path, &["new"]);
let stderr = test_env.jj_cmd_failure(&repo_path, &["bookmark", "create", "foo"]);
let stderr = test_env.jj_cmd_failure(&repo_path, &["bookmark", "create", "-r@", "foo"]);
insta::assert_snapshot!(stderr, @r###"
Error: Bookmark already exists: foo
Hint: Use `jj bookmark set` to update it.
"###);
let (_stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["bookmark", "set", "foo"]);
let (_stdout, stderr) =
test_env.jj_cmd_ok(&repo_path, &["bookmark", "set", "foo", "--revision", "@"]);
insta::assert_snapshot!(stderr, @r###"
Moved 1 bookmarks to mzvwutvl 167f90e7 foo | (empty) (no description set)
"###);
@ -199,7 +196,7 @@ fn test_bookmark_move() {
Moved 1 bookmarks to qpvuntsm 230dd059 foo | (empty) (no description set)
"###);
let (_stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["bookmark", "move", "foo"]);
let (_stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["bookmark", "move", "foo", "--to=@"]);
insta::assert_snapshot!(stderr, @r###"
Moved 1 bookmarks to mzvwutvl 167f90e7 foo | (empty) (no description set)
"###);
@ -228,14 +225,14 @@ fn test_bookmark_move() {
"###);
// Deleted tracking bookmark name should still be allocated
let stderr = test_env.jj_cmd_failure(&repo_path, &["bookmark", "create", "foo"]);
let stderr = test_env.jj_cmd_failure(&repo_path, &["bookmark", "create", "-r@", "foo"]);
insta::assert_snapshot!(stderr, @r###"
Error: Tracked remote bookmarks exist for deleted bookmark: foo
Hint: Use `jj bookmark set` to recreate the local bookmark. Run `jj bookmark untrack 'glob:foo@*'` to disassociate them.
"###);
// Restoring local target shouldn't invalidate tracking state
let (_stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["bookmark", "set", "foo"]);
let (_stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["bookmark", "set", "foo", "--to=@"]);
insta::assert_snapshot!(stderr, @r###"
Moved 1 bookmarks to mzvwutvl 66d48752 foo* | (empty) (no description set)
"###);
@ -247,7 +244,7 @@ fn test_bookmark_move() {
// Untracked remote bookmark shouldn't block creation of local bookmark
test_env.jj_cmd_ok(&repo_path, &["bookmark", "untrack", "foo@origin"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "delete", "foo"]);
let (_stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "foo"]);
let (_stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "foo"]);
insta::assert_snapshot!(stderr, @r###"
Created 1 bookmarks pointing to mzvwutvl 66d48752 foo | (empty) (no description set)
"###);
@ -263,12 +260,12 @@ fn test_bookmark_move_matching() {
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
let repo_path = test_env.env_root().join("repo");
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "a1", "a2"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "a1", "a2"]);
test_env.jj_cmd_ok(&repo_path, &["new", "-mhead1"]);
test_env.jj_cmd_ok(&repo_path, &["new", "root()"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "b1"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "b1"]);
test_env.jj_cmd_ok(&repo_path, &["new"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "c1"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "c1"]);
test_env.jj_cmd_ok(&repo_path, &["new", "-mhead2"]);
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
@ a2781dd9ee37
@ -281,25 +278,28 @@ fn test_bookmark_move_matching() {
"###);
// The default could be considered "--from=all() glob:*", but is disabled
let stderr = test_env.jj_cmd_cli_error(&repo_path, &["bookmark", "move"]);
insta::assert_snapshot!(stderr, @r###"
let stderr = test_env.jj_cmd_cli_error(&repo_path, &["bookmark", "move", "--to=@"]);
insta::assert_snapshot!(stderr, @r"
error: the following required arguments were not provided:
<--from <REVSETS>|NAMES>
Usage: jj bookmark move <--from <REVSETS>|NAMES>
Usage: jj bookmark move --to <REVSET> <--from <REVSETS>|NAMES>
For more information, try '--help'.
"###);
");
// No bookmarks pointing to the source revisions
let (_stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["bookmark", "move", "--from=none()"]);
let (_stdout, stderr) =
test_env.jj_cmd_ok(&repo_path, &["bookmark", "move", "--from=none()", "--to=@"]);
insta::assert_snapshot!(stderr, @r###"
No bookmarks to update.
"###);
// No matching bookmarks within the source revisions
let stderr =
test_env.jj_cmd_failure(&repo_path, &["bookmark", "move", "--from=::@", "glob:a?"]);
let stderr = test_env.jj_cmd_failure(
&repo_path,
&["bookmark", "move", "--from=::@", "glob:a?", "--to=@"],
);
insta::assert_snapshot!(stderr, @r###"
Error: No matching bookmarks for patterns: a?
"###);
@ -311,7 +311,8 @@ fn test_bookmark_move_matching() {
"###);
// Move from multiple revisions
let (_stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["bookmark", "move", "--from=::@"]);
let (_stdout, stderr) =
test_env.jj_cmd_ok(&repo_path, &["bookmark", "move", "--from=::@", "--to=@"]);
insta::assert_snapshot!(stderr, @r###"
Moved 2 bookmarks to vruxwmqv a2781dd9 b1 c1 | (empty) head2
Hint: Specify bookmark by name to update just one of the bookmarks.
@ -328,7 +329,7 @@ fn test_bookmark_move_matching() {
test_env.jj_cmd_ok(&repo_path, &["undo"]);
// Try to move multiple bookmarks, but one of them isn't fast-forward
let stderr = test_env.jj_cmd_failure(&repo_path, &["bookmark", "move", "glob:?1"]);
let stderr = test_env.jj_cmd_failure(&repo_path, &["bookmark", "move", "glob:?1", "--to=@"]);
insta::assert_snapshot!(stderr, @r###"
Error: Refusing to move bookmark backwards or sideways: a1
Hint: Use --allow-backwards to allow it.
@ -449,14 +450,14 @@ fn test_bookmark_rename() {
"###);
test_env.jj_cmd_ok(&repo_path, &["describe", "-m=commit-0"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "blocal"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "blocal"]);
let (_stdout, stderr) =
test_env.jj_cmd_ok(&repo_path, &["bookmark", "rename", "blocal", "blocal1"]);
insta::assert_snapshot!(stderr, @"");
test_env.jj_cmd_ok(&repo_path, &["new"]);
test_env.jj_cmd_ok(&repo_path, &["describe", "-m=commit-1"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "bexist"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "bexist"]);
let stderr = test_env.jj_cmd_failure(&repo_path, &["bookmark", "rename", "blocal1", "bexist"]);
insta::assert_snapshot!(stderr, @r###"
Error: Bookmark already exists: bexist
@ -464,7 +465,7 @@ fn test_bookmark_rename() {
test_env.jj_cmd_ok(&repo_path, &["new"]);
test_env.jj_cmd_ok(&repo_path, &["describe", "-m=commit-2"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "bremote"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "bremote"]);
test_env.jj_cmd_ok(&repo_path, &["git", "push", "--allow-new", "-b=bremote"]);
let (_stdout, stderr) =
test_env.jj_cmd_ok(&repo_path, &["bookmark", "rename", "bremote", "bremote2"]);
@ -487,7 +488,7 @@ fn test_bookmark_rename_colocated() {
let repo_path = test_env.env_root().join("repo");
test_env.jj_cmd_ok(&repo_path, &["describe", "-m=commit-0"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "blocal"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "blocal"]);
// Make sure that git tracking bookmarks don't cause a warning
let (_stdout, stderr) =
@ -501,10 +502,10 @@ fn test_bookmark_forget_glob() {
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
let repo_path = test_env.env_root().join("repo");
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "foo-1"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "bar-2"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "foo-3"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "foo-4"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "foo-1"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "bar-2"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "foo-3"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "foo-4"]);
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
@ bar-2 foo-1 foo-3 foo-4 230dd059e1b0
@ -583,10 +584,10 @@ fn test_bookmark_delete_glob() {
);
test_env.jj_cmd_ok(&repo_path, &["describe", "-m=commit"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "foo-1"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "bar-2"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "foo-3"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "foo-4"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "foo-1"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "bar-2"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "foo-3"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "foo-4"]);
// Push to create remote-tracking bookmarks
test_env.jj_cmd_ok(&repo_path, &["git", "push", "--all"]);
@ -672,7 +673,7 @@ fn test_bookmark_delete_export() {
let repo_path = test_env.env_root().join("repo");
test_env.jj_cmd_ok(&repo_path, &["new"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "foo"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "foo"]);
test_env.jj_cmd_ok(&repo_path, &["git", "export"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "delete", "foo"]);
@ -697,7 +698,7 @@ fn test_bookmark_forget_export() {
let repo_path = test_env.env_root().join("repo");
test_env.jj_cmd_ok(&repo_path, &["new"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "foo"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "foo"]);
insta::assert_snapshot!(get_bookmark_output(&test_env, &repo_path), @r###"
foo: rlvkpnrz 65b6b74e (empty) (no description set)
"###);
@ -946,7 +947,7 @@ fn test_bookmark_track_untrack() {
");
// Track existing bookmark. Local bookmark should result in conflict.
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "feature2"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "feature2"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "track", "feature2@origin"]);
insta::assert_snapshot!(get_bookmark_output(&test_env, &repo_path), @r"
feature1: qxxqrkql bd843888 commit 1
@ -1066,7 +1067,7 @@ fn test_bookmark_track_conflict() {
&repo_path,
&["git", "remote", "add", "origin", "../git-repo"],
);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "main"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "main"]);
test_env.jj_cmd_ok(&repo_path, &["describe", "-m", "a"]);
test_env.jj_cmd_ok(&repo_path, &["git", "push", "--allow-new", "-b", "main"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "untrack", "main@origin"]);
@ -1115,7 +1116,7 @@ fn test_bookmark_track_untrack_patterns() {
"###);
// Track local bookmark
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "main"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "main"]);
insta::assert_snapshot!(
test_env.jj_cmd_cli_error(&repo_path, &["bookmark", "track", "main"]), @r###"
error: invalid value 'main' for '<BOOKMARK@REMOTE>...': remote bookmark must be specified in bookmark@remote form
@ -1224,7 +1225,7 @@ fn test_bookmark_list() {
"remote-delete",
] {
test_env.jj_cmd_ok(&remote_path, &["new", "root()", "-m", bookmark]);
test_env.jj_cmd_ok(&remote_path, &["bookmark", "create", bookmark]);
test_env.jj_cmd_ok(&remote_path, &["bookmark", "create", "-r@", bookmark]);
}
test_env.jj_cmd_ok(&remote_path, &["new"]);
test_env.jj_cmd_ok(&remote_path, &["git", "export"]);
@ -1238,7 +1239,7 @@ fn test_bookmark_list() {
);
let local_path = test_env.env_root().join("local");
test_env.jj_cmd_ok(&local_path, &["new", "root()", "-m", "local-only"]);
test_env.jj_cmd_ok(&local_path, &["bookmark", "create", "local-only"]);
test_env.jj_cmd_ok(&local_path, &["bookmark", "create", "-r@", "local-only"]);
// Mutate refs in local repository
test_env.jj_cmd_ok(&local_path, &["bookmark", "delete", "remote-delete"]);
@ -1249,7 +1250,13 @@ fn test_bookmark_list() {
);
test_env.jj_cmd_ok(
&local_path,
&["bookmark", "set", "--allow-backwards", "remote-unsync"],
&[
"bookmark",
"set",
"--allow-backwards",
"--to=@",
"remote-unsync",
],
);
// Synchronized tracking remotes and non-tracking remotes aren't listed by
@ -1398,7 +1405,7 @@ fn test_bookmark_list_filtered() {
let remote_path = test_env.env_root().join("remote");
for bookmark in ["remote-keep", "remote-delete", "remote-rewrite"] {
test_env.jj_cmd_ok(&remote_path, &["new", "root()", "-m", bookmark]);
test_env.jj_cmd_ok(&remote_path, &["bookmark", "create", bookmark]);
test_env.jj_cmd_ok(&remote_path, &["bookmark", "create", "-r@", bookmark]);
}
test_env.jj_cmd_ok(&remote_path, &["new"]);
test_env.jj_cmd_ok(&remote_path, &["git", "export"]);
@ -1412,7 +1419,7 @@ fn test_bookmark_list_filtered() {
);
let local_path = test_env.env_root().join("local");
test_env.jj_cmd_ok(&local_path, &["new", "root()", "-m", "local-keep"]);
test_env.jj_cmd_ok(&local_path, &["bookmark", "create", "local-keep"]);
test_env.jj_cmd_ok(&local_path, &["bookmark", "create", "-r@", "local-keep"]);
// Mutate refs in local repository
test_env.jj_cmd_ok(&local_path, &["bookmark", "delete", "remote-delete"]);
@ -1624,7 +1631,10 @@ fn test_bookmark_list_much_remote_divergence() {
for _ in 0..15 {
test_env.jj_cmd_ok(&remote_path, &["new", "-m", "remote-unsync"]);
}
test_env.jj_cmd_ok(&remote_path, &["bookmark", "create", "remote-unsync"]);
test_env.jj_cmd_ok(
&remote_path,
&["bookmark", "create", "-r@", "remote-unsync"],
);
test_env.jj_cmd_ok(&remote_path, &["new"]);
test_env.jj_cmd_ok(&remote_path, &["git", "export"]);
@ -1640,12 +1650,18 @@ fn test_bookmark_list_much_remote_divergence() {
for _ in 0..15 {
test_env.jj_cmd_ok(&local_path, &["new", "-m", "local-only"]);
}
test_env.jj_cmd_ok(&local_path, &["bookmark", "create", "local-only"]);
test_env.jj_cmd_ok(&local_path, &["bookmark", "create", "-r@", "local-only"]);
// Mutate refs in local repository
test_env.jj_cmd_ok(
&local_path,
&["bookmark", "set", "--allow-backwards", "remote-unsync"],
&[
"bookmark",
"set",
"--allow-backwards",
"--to=@",
"remote-unsync",
],
);
let (stdout, stderr) = test_env.jj_cmd_ok(&local_path, &["bookmark", "list"]);
@ -1672,7 +1688,7 @@ fn test_bookmark_list_tracked() {
"remote-delete",
] {
test_env.jj_cmd_ok(&remote_path, &["new", "root()", "-m", bookmark]);
test_env.jj_cmd_ok(&remote_path, &["bookmark", "create", bookmark]);
test_env.jj_cmd_ok(&remote_path, &["bookmark", "create", "-r@", bookmark]);
}
test_env.jj_cmd_ok(&remote_path, &["new"]);
test_env.jj_cmd_ok(&remote_path, &["git", "export"]);
@ -1699,7 +1715,10 @@ fn test_bookmark_list_tracked() {
&upstream_git_path,
&["new", "root()", "-m", "upstream-sync"],
);
test_env.jj_cmd_ok(&upstream_git_path, &["bookmark", "create", "upstream-sync"]);
test_env.jj_cmd_ok(
&upstream_git_path,
&["bookmark", "create", "-r@", "upstream-sync"],
);
test_env.jj_cmd_ok(&upstream_git_path, &["new"]);
test_env.jj_cmd_ok(&upstream_git_path, &["git", "export"]);
@ -1720,7 +1739,7 @@ fn test_bookmark_list_tracked() {
test_env.jj_cmd_ok(&local_path, &["git", "fetch", "--all-remotes"]);
test_env.jj_cmd_ok(&local_path, &["new", "root()", "-m", "local-only"]);
test_env.jj_cmd_ok(&local_path, &["bookmark", "create", "local-only"]);
test_env.jj_cmd_ok(&local_path, &["bookmark", "create", "-r@", "local-only"]);
// Mutate refs in local repository
test_env.jj_cmd_ok(&local_path, &["bookmark", "delete", "remote-delete"]);
@ -1743,7 +1762,13 @@ fn test_bookmark_list_tracked() {
);
test_env.jj_cmd_ok(
&local_path,
&["bookmark", "set", "--allow-backwards", "remote-unsync"],
&[
"bookmark",
"set",
"--to=@",
"--allow-backwards",
"remote-unsync",
],
);
let (stdout, stderr) = test_env.jj_cmd_ok(&local_path, &["bookmark", "list", "--all-remotes"]);
@ -1845,7 +1870,7 @@ fn test_bookmark_list_conflicted() {
// Track existing bookmark. Local bookmark should result in conflict.
test_env.jj_cmd_ok(&repo_path, &["new", "root()", "-m", "a"]);
test_env.jj_cmd_ok(&repo_path, &["new", "root()", "-m", "b"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "bar"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "bar"]);
test_env.jj_cmd_ok(
&repo_path,
&["bookmark", "create", "foo", "-r", "description(a)"],
@ -1875,6 +1900,62 @@ fn test_bookmark_list_conflicted() {
"###);
}
#[test]
fn test_bookmark_create_with_default_target_revision() {
let test_env = TestEnvironment::default();
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
let repo_path = test_env.env_root().join("repo");
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "foo"]);
insta::assert_snapshot!(stdout, @"");
insta::assert_snapshot!(stderr, @r"
Warning: Target revision was not specified, defaulting to the working copy (-r@). In the near future it will be required to explicitly specify target revision.
Created 1 bookmarks pointing to qpvuntsm 230dd059 foo | (empty) (no description set)
");
}
#[test]
fn test_bookmark_set_with_default_target_revision() {
let test_env = TestEnvironment::default();
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
let repo_path = test_env.env_root().join("repo");
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["bookmark", "set", "foo"]);
insta::assert_snapshot!(stdout, @"");
insta::assert_snapshot!(stderr, @r"
Warning: Target revision was not specified, defaulting to the working copy (--revision=@). In the near future it will be required to explicitly specify target revision.
Created 1 bookmarks pointing to qpvuntsm 230dd059 foo | (empty) (no description set)
Hint: Consider using `jj bookmark move` if your intention was to move existing bookmarks.
");
}
#[test]
fn test_bookmark_move_with_default_target_revision() {
let test_env = TestEnvironment::default();
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
let repo_path = test_env.env_root().join("repo");
// Set up remote
let git_repo_path = test_env.env_root().join("git-repo");
git2::Repository::init_bare(git_repo_path).unwrap();
test_env.jj_cmd_ok(
&repo_path,
&["git", "remote", "add", "origin", "../git-repo"],
);
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "foo", "-r@"]);
insta::assert_snapshot!(stdout, @"");
insta::assert_snapshot!(stderr, @"Created 1 bookmarks pointing to qpvuntsm 230dd059 foo | (empty) (no description set)");
test_env.jj_cmd_ok(&repo_path, &["new"]);
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["bookmark", "move", "foo"]);
insta::assert_snapshot!(stdout, @"");
insta::assert_snapshot!(stderr, @r"
Warning: Target revision was not specified, defaulting to the working copy (--to=@). In the near future it will be required to explicitly specify it.
Moved 1 bookmarks to zsuskuln 8bb159bc foo | (empty) (no description set)
");
}
fn get_log_output(test_env: &TestEnvironment, cwd: &Path) -> String {
let template = r#"bookmarks ++ " " ++ commit_id.short()"#;
test_env.jj_cmd_success(cwd, &["log", "-T", template])

View File

@ -27,9 +27,12 @@ fn set_up(trunk_name: &str) -> (TestEnvironment, PathBuf) {
.join("git");
test_env.jj_cmd_ok(&origin_path, &["describe", "-m=description 1"]);
test_env.jj_cmd_ok(&origin_path, &["bookmark", "create", trunk_name]);
test_env.jj_cmd_ok(&origin_path, &["bookmark", "create", "-r@", trunk_name]);
test_env.jj_cmd_ok(&origin_path, &["new", "root()", "-m=description 2"]);
test_env.jj_cmd_ok(&origin_path, &["bookmark", "create", "unrelated_bookmark"]);
test_env.jj_cmd_ok(
&origin_path,
&["bookmark", "create", "-r@", "unrelated_bookmark"],
);
test_env.jj_cmd_ok(&origin_path, &["git", "export"]);
test_env.jj_cmd_ok(
@ -87,7 +90,7 @@ fn test_builtin_alias_trunk_matches_exactly_one_commit() {
let (test_env, workspace_root) = set_up("main");
let origin_path = test_env.env_root().join("origin");
test_env.jj_cmd_ok(&origin_path, &["new", "root()", "-m=description 3"]);
test_env.jj_cmd_ok(&origin_path, &["bookmark", "create", "master"]);
test_env.jj_cmd_ok(&origin_path, &["bookmark", "create", "-r@", "master"]);
let stdout = test_env.jj_cmd_success(&workspace_root, &["log", "-r", "trunk()"]);
insta::assert_snapshot!(stdout, @r###"

View File

@ -237,7 +237,7 @@ fn test_log_default() {
std::fs::write(repo_path.join("file1"), "foo\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["describe", "-m", "add a file"]);
test_env.jj_cmd_ok(&repo_path, &["new", "-m", "description 1"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "my-bookmark"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "my-bookmark"]);
// Test default log output format
let stdout = test_env.jj_cmd_success(&repo_path, &["log"]);
@ -297,7 +297,7 @@ fn test_log_builtin_templates() {
&repo_path,
&["--config=user.email=''", "--config=user.name=''", "new"],
);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "my-bookmark"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "my-bookmark"]);
insta::assert_snapshot!(render(r#"builtin_log_oneline"#), @r###"
rlvkpnrz (no email set) 2001-02-03 08:05:08 my-bookmark dc315397 (empty) (no description set)
@ -366,7 +366,7 @@ fn test_log_builtin_templates_colored() {
&repo_path,
&["--config=user.email=''", "--config=user.name=''", "new"],
);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "my-bookmark"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "my-bookmark"]);
insta::assert_snapshot!(render(r#"builtin_log_oneline"#), @r#"
@ rlvkpnrz (no email set) 2001-02-03 08:05:08 my-bookmark dc315397 (empty) (no description set)
@ -430,7 +430,7 @@ fn test_log_builtin_templates_colored_debug() {
&repo_path,
&["--config=user.email=''", "--config=user.name=''", "new"],
);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "my-bookmark"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "my-bookmark"]);
insta::assert_snapshot!(render(r#"builtin_log_oneline"#), @r#"
<<node working_copy::@>> <<log working_copy change_id shortest prefix::r>><<log working_copy change_id shortest rest::lvkpnrz>><<log working_copy:: >><<log working_copy email placeholder::(no email set)>><<log working_copy:: >><<log working_copy committer timestamp local format::2001-02-03 08:05:08>><<log working_copy:: >><<log working_copy bookmarks name::my-bookmark>><<log working_copy:: >><<log working_copy commit_id shortest prefix::d>><<log working_copy commit_id shortest rest::c315397>><<log working_copy:: >><<log working_copy empty::(empty)>><<log working_copy:: >><<log working_copy empty description placeholder::(no description set)>><<log working_copy::>>
@ -565,14 +565,14 @@ fn test_log_bookmarks() {
// Created some bookmarks on the remote
test_env.jj_cmd_ok(&origin_path, &["describe", "-m=description 1"]);
test_env.jj_cmd_ok(&origin_path, &["bookmark", "create", "bookmark1"]);
test_env.jj_cmd_ok(&origin_path, &["bookmark", "create", "-r@", "bookmark1"]);
test_env.jj_cmd_ok(&origin_path, &["new", "root()", "-m=description 2"]);
test_env.jj_cmd_ok(
&origin_path,
&["bookmark", "create", "bookmark2", "unchanged"],
&["bookmark", "create", "-r@", "bookmark2", "unchanged"],
);
test_env.jj_cmd_ok(&origin_path, &["new", "root()", "-m=description 3"]);
test_env.jj_cmd_ok(&origin_path, &["bookmark", "create", "bookmark3"]);
test_env.jj_cmd_ok(&origin_path, &["bookmark", "create", "-r@", "bookmark3"]);
test_env.jj_cmd_ok(&origin_path, &["git", "export"]);
test_env.jj_cmd_ok(
test_env.env_root(),
@ -592,8 +592,11 @@ fn test_log_bookmarks() {
&["describe", "bookmark1", "-m", "modified bookmark1 commit"],
);
test_env.jj_cmd_ok(&workspace_root, &["new", "bookmark2"]);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "set", "bookmark2"]);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "create", "new-bookmark"]);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "set", "bookmark2", "--to=@"]);
test_env.jj_cmd_ok(
&workspace_root,
&["bookmark", "create", "-r@", "new-bookmark"],
);
test_env.jj_cmd_ok(&workspace_root, &["describe", "bookmark3", "-m=local"]);
test_env.jj_cmd_ok(&origin_path, &["describe", "bookmark3", "-m=origin"]);
test_env.jj_cmd_ok(&origin_path, &["git", "export"]);
@ -786,7 +789,7 @@ fn test_log_immutable() {
let repo_path = test_env.env_root().join("repo");
test_env.jj_cmd_ok(&repo_path, &["new", "-mA", "root()"]);
test_env.jj_cmd_ok(&repo_path, &["new", "-mB"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "main"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "main"]);
test_env.jj_cmd_ok(&repo_path, &["new", "-mC"]);
test_env.jj_cmd_ok(&repo_path, &["new", "-mD", "root()"]);
@ -847,7 +850,7 @@ fn test_log_contained_in() {
let repo_path = test_env.env_root().join("repo");
test_env.jj_cmd_ok(&repo_path, &["new", "-mA", "root()"]);
test_env.jj_cmd_ok(&repo_path, &["new", "-mB"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "main"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "main"]);
test_env.jj_cmd_ok(&repo_path, &["new", "-mC"]);
test_env.jj_cmd_ok(&repo_path, &["new", "-mD", "root()"]);

View File

@ -31,8 +31,8 @@ fn test_bookmark_names() {
.join("store")
.join("git");
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "aaa-local"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "bbb-local"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "aaa-local"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "bbb-local"]);
// add various remote branches
test_env.jj_cmd_ok(
@ -45,18 +45,24 @@ fn test_bookmark_names() {
origin_git_repo_path.to_str().unwrap(),
],
);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "aaa-tracked"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "aaa-tracked"]);
test_env.jj_cmd_ok(&repo_path, &["desc", "-r", "aaa-tracked", "-m", "x"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "bbb-tracked"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "bbb-tracked"]);
test_env.jj_cmd_ok(&repo_path, &["desc", "-r", "bbb-tracked", "-m", "x"]);
test_env.jj_cmd_ok(
&repo_path,
&["git", "push", "--allow-new", "--bookmark", "glob:*-tracked"],
);
test_env.jj_cmd_ok(&origin_path, &["bookmark", "create", "aaa-untracked"]);
test_env.jj_cmd_ok(
&origin_path,
&["bookmark", "create", "-r@", "aaa-untracked"],
);
test_env.jj_cmd_ok(&origin_path, &["desc", "-r", "aaa-untracked", "-m", "x"]);
test_env.jj_cmd_ok(&origin_path, &["bookmark", "create", "bbb-untracked"]);
test_env.jj_cmd_ok(
&origin_path,
&["bookmark", "create", "-r@", "bbb-untracked"],
);
test_env.jj_cmd_ok(&origin_path, &["desc", "-r", "bbb-untracked", "-m", "x"]);
test_env.jj_cmd_ok(&origin_path, &["git", "export"]);
test_env.jj_cmd_ok(&repo_path, &["git", "fetch"]);
@ -154,7 +160,7 @@ fn test_global_arg_repository_is_respected() {
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
let repo_path = test_env.env_root().join("repo");
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "aaa"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "aaa"]);
let mut test_env = test_env;
test_env.add_env_var("COMPLETE", "fish");
@ -181,7 +187,7 @@ fn test_aliases_are_resolved() {
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
let repo_path = test_env.env_root().join("repo");
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "aaa"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "aaa"]);
// user config alias
test_env.add_config(r#"aliases.b = ["bookmark"]"#);
@ -373,12 +379,12 @@ fn test_revisions() {
origin_git_repo_path.to_str().unwrap(),
],
);
test_env.jj_cmd_ok(&origin_path, &["b", "c", "remote_bookmark"]);
test_env.jj_cmd_ok(&origin_path, &["b", "c", "-r@", "remote_bookmark"]);
test_env.jj_cmd_ok(&origin_path, &["commit", "-m", "remote_commit"]);
test_env.jj_cmd_ok(&origin_path, &["git", "export"]);
test_env.jj_cmd_ok(&repo_path, &["git", "fetch"]);
test_env.jj_cmd_ok(&repo_path, &["b", "c", "immutable_bookmark"]);
test_env.jj_cmd_ok(&repo_path, &["b", "c", "-r@", "immutable_bookmark"]);
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "immutable"]);
test_env.add_config(r#"revset-aliases."immutable_heads()" = "immutable_bookmark""#);
test_env.add_config(r#"revset-aliases."siblings" = "@-+ ~@""#);
@ -390,7 +396,7 @@ fn test_revisions() {
'''"#,
);
test_env.jj_cmd_ok(&repo_path, &["b", "c", "mutable_bookmark"]);
test_env.jj_cmd_ok(&repo_path, &["b", "c", "-r@", "mutable_bookmark"]);
test_env.jj_cmd_ok(&repo_path, &["commit", "-m", "mutable"]);
test_env.jj_cmd_ok(&repo_path, &["describe", "-m", "working_copy"]);
@ -627,7 +633,7 @@ fn create_commit(
None => std::fs::remove_file(repo_path.join(name)).unwrap(),
}
}
test_env.jj_cmd_ok(repo_path, &["bookmark", "create", name]);
test_env.jj_cmd_ok(repo_path, &["bookmark", "create", "-r@", name]);
}
#[test]

View File

@ -544,7 +544,7 @@ fn test_diffedit_merge() {
std::fs::write(repo_path.join("file1"), "a\n").unwrap();
std::fs::write(repo_path.join("file2"), "a\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["new"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "b"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "b"]);
std::fs::write(repo_path.join("file1"), "b\n").unwrap();
std::fs::write(repo_path.join("file2"), "b\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["new", "@-"]);

View File

@ -25,7 +25,7 @@ fn create_commit(test_env: &TestEnvironment, repo_path: &Path, name: &str, paren
test_env.jj_cmd_ok(repo_path, &args);
}
std::fs::write(repo_path.join(name), format!("{name}\n")).unwrap();
test_env.jj_cmd_ok(repo_path, &["bookmark", "create", name]);
test_env.jj_cmd_ok(repo_path, &["bookmark", "create", "-r@", name]);
}
#[test]
@ -75,9 +75,7 @@ fn test_duplicate() {
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["undo"]);
insta::assert_snapshot!(stdout, @"");
insta::assert_snapshot!(stderr, @r#"
Undid operation: b5bdbb51ab28 (2001-02-03 08:05:17) duplicate 1 commit(s)
"#);
insta::assert_snapshot!(stderr, @"Undid operation: 01373b278eae (2001-02-03 08:05:17) duplicate 1 commit(s)");
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["duplicate" /* duplicates `c` */]);
insta::assert_snapshot!(stdout, @"");
insta::assert_snapshot!(stderr, @r###"
@ -2327,9 +2325,7 @@ fn test_undo_after_duplicate() {
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["undo"]);
insta::assert_snapshot!(stdout, @"");
insta::assert_snapshot!(stderr, @r#"
Undid operation: e3dbefa46ed5 (2001-02-03 08:05:11) duplicate 1 commit(s)
"#);
insta::assert_snapshot!(stderr, @"Undid operation: 7e9bd644ad7a (2001-02-03 08:05:11) duplicate 1 commit(s)");
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
@ 2443ea76b0b1 a
000000000000

View File

@ -55,15 +55,15 @@ fn test_annotate_merge() {
std::fs::write(repo_path.join("file.txt"), "line1\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["describe", "-m=initial"]);
test_env.jj_cmd_ok(&repo_path, &["branch", "create", "initial"]);
test_env.jj_cmd_ok(&repo_path, &["branch", "create", "-r@", "initial"]);
test_env.jj_cmd_ok(&repo_path, &["new", "-m=commit1"]);
append_to_file(&repo_path.join("file.txt"), "new text from new commit 1");
test_env.jj_cmd_ok(&repo_path, &["branch", "create", "commit1"]);
test_env.jj_cmd_ok(&repo_path, &["branch", "create", "-r@", "commit1"]);
test_env.jj_cmd_ok(&repo_path, &["new", "-m=commit2", "initial"]);
append_to_file(&repo_path.join("file.txt"), "new text from new commit 2");
test_env.jj_cmd_ok(&repo_path, &["branch", "create", "commit2"]);
test_env.jj_cmd_ok(&repo_path, &["branch", "create", "-r@", "commit2"]);
// create a (conflicted) merge
test_env.jj_cmd_ok(&repo_path, &["new", "-m=merged", "commit1", "commit2"]);
@ -90,15 +90,15 @@ fn test_annotate_conflicted() {
std::fs::write(repo_path.join("file.txt"), "line1\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["describe", "-m=initial"]);
test_env.jj_cmd_ok(&repo_path, &["branch", "create", "initial"]);
test_env.jj_cmd_ok(&repo_path, &["branch", "create", "-r@", "initial"]);
test_env.jj_cmd_ok(&repo_path, &["new", "-m=commit1"]);
append_to_file(&repo_path.join("file.txt"), "new text from new commit 1");
test_env.jj_cmd_ok(&repo_path, &["branch", "create", "commit1"]);
test_env.jj_cmd_ok(&repo_path, &["branch", "create", "-r@", "commit1"]);
test_env.jj_cmd_ok(&repo_path, &["new", "-m=commit2", "initial"]);
append_to_file(&repo_path.join("file.txt"), "new text from new commit 2");
test_env.jj_cmd_ok(&repo_path, &["branch", "create", "commit2"]);
test_env.jj_cmd_ok(&repo_path, &["branch", "create", "-r@", "commit2"]);
// create a (conflicted) merge
test_env.jj_cmd_ok(&repo_path, &["new", "-m=merged", "commit1", "commit2"]);
@ -124,15 +124,15 @@ fn test_annotate_merge_one_sided_conflict_resolution() {
std::fs::write(repo_path.join("file.txt"), "line1\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["describe", "-m=initial"]);
test_env.jj_cmd_ok(&repo_path, &["branch", "create", "initial"]);
test_env.jj_cmd_ok(&repo_path, &["branch", "create", "-r@", "initial"]);
test_env.jj_cmd_ok(&repo_path, &["new", "-m=commit1"]);
append_to_file(&repo_path.join("file.txt"), "new text from new commit 1");
test_env.jj_cmd_ok(&repo_path, &["branch", "create", "commit1"]);
test_env.jj_cmd_ok(&repo_path, &["branch", "create", "-r@", "commit1"]);
test_env.jj_cmd_ok(&repo_path, &["new", "-m=commit2", "initial"]);
append_to_file(&repo_path.join("file.txt"), "new text from new commit 2");
test_env.jj_cmd_ok(&repo_path, &["branch", "create", "commit2"]);
test_env.jj_cmd_ok(&repo_path, &["branch", "create", "-r@", "commit2"]);
// create a (conflicted) merge
test_env.jj_cmd_ok(&repo_path, &["new", "-m=merged", "commit1", "commit2"]);

View File

@ -33,7 +33,7 @@ fn create_commit(
for (name, content) in files {
std::fs::write(repo_path.join(name), content).unwrap();
}
test_env.jj_cmd_ok(repo_path, &["bookmark", "create", name]);
test_env.jj_cmd_ok(repo_path, &["bookmark", "create", "-r@", name]);
}
fn get_log_output(test_env: &TestEnvironment, repo_path: &Path) -> String {

View File

@ -476,13 +476,13 @@ fn test_fix_parent_commit() {
let (test_env, repo_path) = init_with_fake_formatter(&["--uppercase"]);
// Using one file name for all commits adds coverage of some possible bugs.
std::fs::write(repo_path.join("file"), "parent").unwrap();
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "parent"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "parent"]);
test_env.jj_cmd_ok(&repo_path, &["new"]);
std::fs::write(repo_path.join("file"), "child1").unwrap();
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "child1"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "child1"]);
test_env.jj_cmd_ok(&repo_path, &["new", "-r", "parent"]);
std::fs::write(repo_path.join("file"), "child2").unwrap();
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "child2"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "child2"]);
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["fix", "-s", "parent"]);
insta::assert_snapshot!(stdout, @"");
@ -504,13 +504,13 @@ fn test_fix_parent_commit() {
fn test_fix_sibling_commit() {
let (test_env, repo_path) = init_with_fake_formatter(&["--uppercase"]);
std::fs::write(repo_path.join("file"), "parent").unwrap();
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "parent"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "parent"]);
test_env.jj_cmd_ok(&repo_path, &["new"]);
std::fs::write(repo_path.join("file"), "child1").unwrap();
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "child1"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "child1"]);
test_env.jj_cmd_ok(&repo_path, &["new", "-r", "parent"]);
std::fs::write(repo_path.join("file"), "child2").unwrap();
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "child2"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "child2"]);
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["fix", "-s", "child1"]);
insta::assert_snapshot!(stdout, @"");
@ -527,22 +527,22 @@ fn test_fix_sibling_commit() {
fn test_default_revset() {
let (test_env, repo_path) = init_with_fake_formatter(&["--uppercase"]);
std::fs::write(repo_path.join("file"), "trunk1").unwrap();
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "trunk1"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "trunk1"]);
test_env.jj_cmd_ok(&repo_path, &["new"]);
std::fs::write(repo_path.join("file"), "trunk2").unwrap();
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "trunk2"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "trunk2"]);
test_env.jj_cmd_ok(&repo_path, &["new", "trunk1"]);
std::fs::write(repo_path.join("file"), "foo").unwrap();
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "foo"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "foo"]);
test_env.jj_cmd_ok(&repo_path, &["new", "trunk1"]);
std::fs::write(repo_path.join("file"), "bar1").unwrap();
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "bar1"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "bar1"]);
test_env.jj_cmd_ok(&repo_path, &["new"]);
std::fs::write(repo_path.join("file"), "bar2").unwrap();
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "bar2"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "bar2"]);
test_env.jj_cmd_ok(&repo_path, &["new"]);
std::fs::write(repo_path.join("file"), "bar3").unwrap();
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "bar3"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "bar3"]);
test_env.jj_cmd_ok(&repo_path, &["edit", "bar2"]);
// With no args and no revset configuration, we fix `reachable(@, mutable())`,
@ -576,10 +576,10 @@ fn test_custom_default_revset() {
let (test_env, repo_path) = init_with_fake_formatter(&["--uppercase"]);
std::fs::write(repo_path.join("file"), "foo").unwrap();
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "foo"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "foo"]);
test_env.jj_cmd_ok(&repo_path, &["new"]);
std::fs::write(repo_path.join("file"), "bar").unwrap();
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "bar"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "bar"]);
// Check out a different commit so that the schema default `reachable(@,
// mutable())` would behave differently from our customized default.
@ -599,10 +599,10 @@ fn test_custom_default_revset() {
fn test_fix_immutable_commit() {
let (test_env, repo_path) = init_with_fake_formatter(&["--uppercase"]);
std::fs::write(repo_path.join("file"), "immutable").unwrap();
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "immutable"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "immutable"]);
test_env.jj_cmd_ok(&repo_path, &["new"]);
std::fs::write(repo_path.join("file"), "mutable").unwrap();
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "mutable"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "mutable"]);
test_env.add_config(r#"revset-aliases."immutable_heads()" = "immutable""#);
let stderr = test_env.jj_cmd_failure(&repo_path, &["fix", "-s", "immutable"]);
@ -692,16 +692,16 @@ fn test_deduplication() {
// There are at least two interesting cases: the content is repeated immediately
// in the child commit, or later in another descendant.
std::fs::write(repo_path.join("file"), "foo\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "a"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "a"]);
test_env.jj_cmd_ok(&repo_path, &["new"]);
std::fs::write(repo_path.join("file"), "bar\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "b"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "b"]);
test_env.jj_cmd_ok(&repo_path, &["new"]);
std::fs::write(repo_path.join("file"), "bar\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "c"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "c"]);
test_env.jj_cmd_ok(&repo_path, &["new"]);
std::fs::write(repo_path.join("file"), "foo\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "d"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "d"]);
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["fix", "-s", "a"]);
insta::assert_snapshot!(stdout, @"");
@ -877,11 +877,11 @@ fn test_fix_trivial_merge_commit() {
let (test_env, repo_path) = init_with_fake_formatter(&["--uppercase"]);
std::fs::write(repo_path.join("file_a"), "content a").unwrap();
std::fs::write(repo_path.join("file_c"), "content c").unwrap();
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "a"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "a"]);
test_env.jj_cmd_ok(&repo_path, &["new", "@-"]);
std::fs::write(repo_path.join("file_b"), "content b").unwrap();
std::fs::write(repo_path.join("file_c"), "content c").unwrap();
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "b"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "b"]);
test_env.jj_cmd_ok(&repo_path, &["new", "a", "b"]);
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["fix", "-s", "@"]);
@ -905,11 +905,11 @@ fn test_fix_adding_merge_commit() {
let (test_env, repo_path) = init_with_fake_formatter(&["--uppercase"]);
std::fs::write(repo_path.join("file_a"), "content a").unwrap();
std::fs::write(repo_path.join("file_c"), "content c").unwrap();
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "a"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "a"]);
test_env.jj_cmd_ok(&repo_path, &["new", "@-"]);
std::fs::write(repo_path.join("file_b"), "content b").unwrap();
std::fs::write(repo_path.join("file_c"), "content c").unwrap();
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "b"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "b"]);
test_env.jj_cmd_ok(&repo_path, &["new", "a", "b"]);
std::fs::write(repo_path.join("file_a"), "change a").unwrap();
std::fs::write(repo_path.join("file_b"), "change b").unwrap();
@ -939,10 +939,10 @@ fn test_fix_adding_merge_commit() {
fn test_fix_both_sides_of_conflict() {
let (test_env, repo_path) = init_with_fake_formatter(&["--uppercase"]);
std::fs::write(repo_path.join("file"), "content a\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "a"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "a"]);
test_env.jj_cmd_ok(&repo_path, &["new", "@-"]);
std::fs::write(repo_path.join("file"), "content b\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "b"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "b"]);
test_env.jj_cmd_ok(&repo_path, &["new", "a", "b"]);
// The conflicts are not different from the merged parent, so they would not be
@ -983,10 +983,10 @@ fn test_fix_resolve_conflict() {
// will be resolved.
let (test_env, repo_path) = init_with_fake_formatter(&["--uppercase"]);
std::fs::write(repo_path.join("file"), "Content\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "a"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "a"]);
test_env.jj_cmd_ok(&repo_path, &["new", "@-"]);
std::fs::write(repo_path.join("file"), "cOnTeNt\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "b"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "b"]);
test_env.jj_cmd_ok(&repo_path, &["new", "a", "b"]);
// The conflicts are not different from the merged parent, so they would not be

View File

@ -244,7 +244,7 @@ fn test_git_colocated_export_bookmarks_on_snapshot() {
// Create bookmark pointing to the initial commit
std::fs::write(workspace_root.join("file"), "initial").unwrap();
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "create", "foo"]);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "create", "-r@", "foo"]);
insta::assert_snapshot!(get_log_output(&test_env, &workspace_root), @r###"
@ b15ef4cdd277d2c63cce6d67c1916f53a36141f7 foo
0000000000000000000000000000000000000000
@ -276,7 +276,7 @@ fn test_git_colocated_rebase_on_import() {
std::fs::write(workspace_root.join("file"), "contents").unwrap();
test_env.jj_cmd_ok(&workspace_root, &["commit", "-m", "add a file"]);
std::fs::write(workspace_root.join("file"), "modified").unwrap();
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "create", "master"]);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "create", "-r@", "master"]);
test_env.jj_cmd_ok(&workspace_root, &["commit", "-m", "modify a file"]);
// TODO: We shouldn't need this command here to trigger an import of the
// refs/heads/master we just exported
@ -327,7 +327,7 @@ fn test_git_colocated_bookmarks() {
// Create a bookmark in jj. It should be exported to Git even though it points
// to the working- copy commit.
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "create", "master"]);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "create", "-r@", "master"]);
insta::assert_snapshot!(
git_repo.find_reference("refs/heads/master").unwrap().target().unwrap().to_string(),
@"3560559274ab431feea00b7b7e0b9250ecce951f"
@ -373,7 +373,7 @@ fn test_git_colocated_bookmark_forget() {
let _git_repo = git2::Repository::init(&workspace_root).unwrap();
test_env.jj_cmd_ok(&workspace_root, &["git", "init", "--git-repo", "."]);
test_env.jj_cmd_ok(&workspace_root, &["new"]);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "create", "foo"]);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "create", "-r@", "foo"]);
insta::assert_snapshot!(get_log_output(&test_env, &workspace_root), @r#"
@ 65b6b74e08973b88d38404430f119c8c79465250 foo
230dd059e1b059aefc0da06a2e5a7dbf22362f22 git_head()
@ -409,7 +409,7 @@ fn test_git_colocated_bookmark_at_root() {
foo: Ref cannot point to the root commit in Git
"###);
let (_stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["bookmark", "move", "foo"]);
let (_stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["bookmark", "move", "foo", "--to=@"]);
insta::assert_snapshot!(stderr, @r###"
Moved 1 bookmarks to qpvuntsm 230dd059 foo | (empty) (no description set)
"###);
@ -437,8 +437,9 @@ fn test_git_colocated_conflicting_git_refs() {
let workspace_root = test_env.env_root().join("repo");
git2::Repository::init(&workspace_root).unwrap();
test_env.jj_cmd_ok(&workspace_root, &["git", "init", "--git-repo", "."]);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "create", "main"]);
let (stdout, stderr) = test_env.jj_cmd_ok(&workspace_root, &["bookmark", "create", "main/sub"]);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "create", "-r@", "main"]);
let (stdout, stderr) =
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "create", "-r@", "main/sub"]);
insta::assert_snapshot!(stdout, @"");
insta::with_settings!({filters => vec![("Failed to set: .*", "Failed to set: ...")]}, {
insta::assert_snapshot!(stderr, @r###"
@ -522,11 +523,11 @@ fn test_git_colocated_fetch_deleted_or_moved_bookmark() {
git2::Repository::init(&origin_path).unwrap();
test_env.jj_cmd_ok(&origin_path, &["git", "init", "--git-repo=."]);
test_env.jj_cmd_ok(&origin_path, &["describe", "-m=A"]);
test_env.jj_cmd_ok(&origin_path, &["bookmark", "create", "A"]);
test_env.jj_cmd_ok(&origin_path, &["bookmark", "create", "-r@", "A"]);
test_env.jj_cmd_ok(&origin_path, &["new", "-m=B_to_delete"]);
test_env.jj_cmd_ok(&origin_path, &["bookmark", "create", "B_to_delete"]);
test_env.jj_cmd_ok(&origin_path, &["bookmark", "create", "-r@", "B_to_delete"]);
test_env.jj_cmd_ok(&origin_path, &["new", "-m=original C", "@-"]);
test_env.jj_cmd_ok(&origin_path, &["bookmark", "create", "C_to_move"]);
test_env.jj_cmd_ok(&origin_path, &["bookmark", "create", "-r@", "C_to_move"]);
let clone_path = test_env.env_root().join("clone");
git2::Repository::clone(origin_path.to_str().unwrap(), &clone_path).unwrap();
@ -573,7 +574,7 @@ fn test_git_colocated_rebase_dirty_working_copy() {
std::fs::write(repo_path.join("file"), "base").unwrap();
test_env.jj_cmd_ok(&repo_path, &["new"]);
std::fs::write(repo_path.join("file"), "old").unwrap();
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "feature"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "feature"]);
// Make the working-copy dirty, delete the checked out bookmark.
std::fs::write(repo_path.join("file"), "new").unwrap();
@ -782,14 +783,14 @@ fn test_git_colocated_update_index_preserves_timestamps() {
std::fs::write(repo_path.join("file1.txt"), "will be unchanged\n").unwrap();
std::fs::write(repo_path.join("file2.txt"), "will be modified\n").unwrap();
std::fs::write(repo_path.join("file3.txt"), "will be deleted\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "commit1"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "commit1"]);
test_env.jj_cmd_ok(&repo_path, &["new"]);
// Create a commit with some changes to the files
std::fs::write(repo_path.join("file2.txt"), "modified\n").unwrap();
std::fs::remove_file(repo_path.join("file3.txt")).unwrap();
std::fs::write(repo_path.join("file4.txt"), "added\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "commit2"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "commit2"]);
test_env.jj_cmd_ok(&repo_path, &["new"]);
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r#"
@ -861,17 +862,17 @@ fn test_git_colocated_update_index_merge_conflict() {
// Set up conflict files
std::fs::write(repo_path.join("conflict.txt"), "base\n").unwrap();
std::fs::write(repo_path.join("base.txt"), "base\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "base"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "base"]);
test_env.jj_cmd_ok(&repo_path, &["new", "base"]);
std::fs::write(repo_path.join("conflict.txt"), "left\n").unwrap();
std::fs::write(repo_path.join("left.txt"), "left\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "left"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "left"]);
test_env.jj_cmd_ok(&repo_path, &["new", "base"]);
std::fs::write(repo_path.join("conflict.txt"), "right\n").unwrap();
std::fs::write(repo_path.join("right.txt"), "right\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "right"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "right"]);
insta::assert_snapshot!(get_index_state(&repo_path), @r#"
Unconflicted Mode(FILE) df967b96a579 ctime=0:0 mtime=0:0 size=0 base.txt
@ -943,17 +944,17 @@ fn test_git_colocated_update_index_rebase_conflict() {
// Set up conflict files
std::fs::write(repo_path.join("conflict.txt"), "base\n").unwrap();
std::fs::write(repo_path.join("base.txt"), "base\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "base"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "base"]);
test_env.jj_cmd_ok(&repo_path, &["new", "base"]);
std::fs::write(repo_path.join("conflict.txt"), "left\n").unwrap();
std::fs::write(repo_path.join("left.txt"), "left\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "left"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "left"]);
test_env.jj_cmd_ok(&repo_path, &["new", "base"]);
std::fs::write(repo_path.join("conflict.txt"), "right\n").unwrap();
std::fs::write(repo_path.join("right.txt"), "right\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "right"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "right"]);
test_env.jj_cmd_ok(&repo_path, &["edit", "left"]);
@ -1027,22 +1028,22 @@ fn test_git_colocated_update_index_3_sided_conflict() {
// Set up conflict files
std::fs::write(repo_path.join("conflict.txt"), "base\n").unwrap();
std::fs::write(repo_path.join("base.txt"), "base\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "base"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "base"]);
test_env.jj_cmd_ok(&repo_path, &["new", "base"]);
std::fs::write(repo_path.join("conflict.txt"), "side-1\n").unwrap();
std::fs::write(repo_path.join("side-1.txt"), "side-1\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "side-1"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "side-1"]);
test_env.jj_cmd_ok(&repo_path, &["new", "base"]);
std::fs::write(repo_path.join("conflict.txt"), "side-2\n").unwrap();
std::fs::write(repo_path.join("side-2.txt"), "side-2\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "side-2"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "side-2"]);
test_env.jj_cmd_ok(&repo_path, &["new", "base"]);
std::fs::write(repo_path.join("conflict.txt"), "side-3\n").unwrap();
std::fs::write(repo_path.join("side-3.txt"), "side-3\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "side-3"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "side-3"]);
insta::assert_snapshot!(get_index_state(&repo_path), @r#"
Unconflicted Mode(FILE) df967b96a579 ctime=0:0 mtime=0:0 size=0 base.txt

View File

@ -78,7 +78,7 @@ fn create_commit(test_env: &TestEnvironment, repo_path: &Path, name: &str, paren
test_env.jj_cmd_ok(repo_path, &args);
}
std::fs::write(repo_path.join(name), format!("{name}\n")).unwrap();
test_env.jj_cmd_ok(repo_path, &["bookmark", "create", name]);
test_env.jj_cmd_ok(repo_path, &["bookmark", "create", "-r@", name]);
}
fn get_log_output(test_env: &TestEnvironment, workspace_root: &Path) -> String {
@ -484,7 +484,7 @@ fn test_git_fetch_conflicting_bookmarks(subprocess: bool) {
// Create a rem1 bookmark locally
test_env.jj_cmd_ok(&repo_path, &["new", "root()"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "rem1"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "rem1"]);
insta::allow_duplicates! {
insta::assert_snapshot!(get_bookmark_output(&test_env, &repo_path), @r###"
rem1: kkmpptxz fcdbbd73 (empty) (no description set)
@ -525,7 +525,7 @@ fn test_git_fetch_conflicting_bookmarks_colocated(subprocess: bool) {
// Create a rem1 bookmark locally
test_env.jj_cmd_ok(&repo_path, &["new", "root()"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "rem1"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "rem1"]);
insta::allow_duplicates! {
insta::assert_snapshot!(get_bookmark_output(&test_env, &repo_path), @r###"
rem1: zsuskuln f652c321 (empty) (no description set)
@ -1372,7 +1372,7 @@ fn test_fetch_undo_what(subprocess: bool) {
// Now, let's demo restoring just the remote-tracking bookmark. First, let's
// change our local repo state...
test_env.jj_cmd_ok(&repo_path, &["bookmark", "c", "newbookmark"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "c", "-r@", "newbookmark"]);
insta::allow_duplicates! {
insta::assert_snapshot!(get_bookmark_output(&test_env, &repo_path), @r###"
b (deleted)
@ -1419,7 +1419,7 @@ fn test_git_fetch_remove_fetch(subprocess: bool) {
let repo_path = test_env.env_root().join("repo");
add_git_remote(&test_env, &repo_path, "origin");
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "origin"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "origin"]);
insta::allow_duplicates! {
insta::assert_snapshot!(get_bookmark_output(&test_env, &repo_path), @r###"
origin: qpvuntsm 230dd059 (empty) (no description set)
@ -1479,7 +1479,7 @@ fn test_git_fetch_rename_fetch(subprocess: bool) {
let repo_path = test_env.env_root().join("repo");
add_git_remote(&test_env, &repo_path, "origin");
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "origin"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "origin"]);
insta::allow_duplicates! {
insta::assert_snapshot!(get_bookmark_output(&test_env, &repo_path), @r###"
origin: qpvuntsm 230dd059 (empty) (no description set)

View File

@ -24,7 +24,7 @@ fn test_resolution_of_git_tracking_bookmarks() {
let test_env = TestEnvironment::default();
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
let repo_path = test_env.env_root().join("repo");
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "main"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "main"]);
test_env.jj_cmd_ok(&repo_path, &["describe", "-r", "main", "-m", "old_message"]);
// Create local-git tracking bookmark
@ -62,8 +62,8 @@ fn test_git_export_conflicting_git_refs() {
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
let repo_path = test_env.env_root().join("repo");
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "main"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "main/sub"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "main"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "main/sub"]);
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["git", "export"]);
insta::assert_snapshot!(stdout, @"");
insta::with_settings!({filters => vec![("Failed to set: .*", "Failed to set: ...")]}, {
@ -84,7 +84,7 @@ fn test_git_export_undo() {
let repo_path = test_env.env_root().join("repo");
let git_repo = git::open(repo_path.join(".jj/repo/store/git"));
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "a"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "a"]);
insta::assert_snapshot!(get_bookmark_output(&test_env, &repo_path), @r###"
a: qpvuntsm 230dd059 (empty) (no description set)
"###);
@ -101,9 +101,7 @@ fn test_git_export_undo() {
// bookmark is. This is the same as remote-tracking bookmarks.
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["op", "undo"]);
insta::assert_snapshot!(stdout, @"");
insta::assert_snapshot!(stderr, @r#"
Undid operation: b27a68390bea (2001-02-03 08:05:10) export git refs
"#);
insta::assert_snapshot!(stderr, @"Undid operation: edb40232c741 (2001-02-03 08:05:10) export git refs");
insta::assert_debug_snapshot!(get_git_repo_refs(&git_repo), @r###"
[
(
@ -220,7 +218,7 @@ fn test_git_import_move_export_with_default_undo() {
// Move bookmark "a" and export to git repo
test_env.jj_cmd_ok(&repo_path, &["new"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "set", "a"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "set", "a", "--to=@"]);
insta::assert_snapshot!(get_bookmark_output(&test_env, &repo_path), @r###"
a: yqosqzyt 096dc80d (empty) (no description set)
@git (behind by 1 commits): qpvuntsm 230dd059 (empty) (no description set)

View File

@ -529,7 +529,7 @@ fn test_git_init_colocated_via_git_repo_path_imported_refs() {
let remote_path = test_env.env_root().join("remote");
test_env.jj_cmd_ok(
&remote_path,
&["bookmark", "create", "local-remote", "remote-only"],
&["bookmark", "create", "-r@", "local-remote", "remote-only"],
);
test_env.jj_cmd_ok(&remote_path, &["new"]);
test_env.jj_cmd_ok(&remote_path, &["git", "export"]);
@ -762,7 +762,10 @@ fn test_git_init_colocated_via_flag_git_dir_not_exists() {
"###);
// Create the default bookmark (create both in case we change the default)
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "create", "main", "master"]);
test_env.jj_cmd_ok(
&workspace_root,
&["bookmark", "create", "-r@", "main", "master"],
);
// If .git/HEAD pointed to the default bookmark, new working-copy commit would
// be created on top.

View File

@ -29,7 +29,7 @@ fn set_up() -> (TestEnvironment, PathBuf) {
test_env.jj_cmd_ok(&origin_path, &["describe", "-m=public 1"]);
test_env.jj_cmd_ok(&origin_path, &["new", "-m=public 2"]);
test_env.jj_cmd_ok(&origin_path, &["bookmark", "create", "main"]);
test_env.jj_cmd_ok(&origin_path, &["bookmark", "create", "-r@", "main"]);
test_env.jj_cmd_ok(&origin_path, &["git", "export"]);
test_env.jj_cmd_ok(
@ -83,7 +83,7 @@ fn test_git_private_commits_block_pushing() {
let (test_env, workspace_root) = set_up();
test_env.jj_cmd_ok(&workspace_root, &["new", "main", "-m=private 1"]);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "set", "main"]);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "set", "main", "-r@"]);
// Will not push when a pushed commit is contained in git.private-commits
test_env.add_config(r#"git.private-commits = "description(glob:'private*')""#);
@ -111,7 +111,7 @@ fn test_git_private_commits_can_be_overridden() {
let (test_env, workspace_root) = set_up();
test_env.jj_cmd_ok(&workspace_root, &["new", "main", "-m=private 1"]);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "set", "main"]);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "set", "main", "-r@"]);
// Will not push when a pushed commit is contained in git.private-commits
test_env.add_config(r#"git.private-commits = "description(glob:'private*')""#);
@ -141,7 +141,7 @@ fn test_git_private_commits_are_not_checked_if_immutable() {
let (test_env, workspace_root) = set_up();
test_env.jj_cmd_ok(&workspace_root, &["new", "main", "-m=private 1"]);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "set", "main"]);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "set", "main", "-r@"]);
test_env.add_config(r#"git.private-commits = "description(glob:'private*')""#);
test_env.add_config(r#"revset-aliases."immutable_heads()" = "all()""#);
@ -163,7 +163,7 @@ fn test_git_private_commits_not_directly_in_line_block_pushing() {
test_env.jj_cmd_ok(&workspace_root, &["new", "root()", "-m=private 1"]);
test_env.jj_cmd_ok(&workspace_root, &["new", "main", "@", "-m=public 3"]);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "create", "bookmark1"]);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "create", "-r@", "bookmark1"]);
test_env.add_config(r#"git.private-commits = "description(glob:'private*')""#);
let stderr = test_env.jj_cmd_failure(
@ -182,7 +182,7 @@ fn test_git_private_commits_descending_from_commits_pushed_do_not_block_pushing(
let (test_env, workspace_root) = set_up();
test_env.jj_cmd_ok(&workspace_root, &["new", "main", "-m=public 3"]);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "move", "main"]);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "move", "main", "--to=@"]);
test_env.jj_cmd_ok(&workspace_root, &["new", "-m=private 1"]);
test_env.add_config(r#"git.private-commits = "description(glob:'private*')""#);
@ -207,7 +207,7 @@ fn test_git_private_commits_already_on_the_remote_do_not_block_push() {
// the remote
test_env.jj_cmd_ok(&workspace_root, &["new", "main", "-m=private 1"]);
test_env.jj_cmd_ok(&workspace_root, &["new", "-m=public 3"]);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "set", "main"]);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "set", "main", "-r@"]);
let (_, stderr) = test_env.jj_cmd_ok(
&workspace_root,
&["git", "push", "--allow-new", "-b=main", "-b=bookmark1"],
@ -240,7 +240,7 @@ fn test_git_private_commits_already_on_the_remote_do_not_block_push() {
&workspace_root,
&["new", "description('private 1')", "-m=public 4"],
);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "create", "bookmark2"]);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "create", "-r@", "bookmark2"]);
let (_, stderr) = test_env.jj_cmd_ok(
&workspace_root,
&["git", "push", "--allow-new", "-b=bookmark2"],
@ -261,7 +261,7 @@ fn test_git_private_commits_are_evaluated_separately_for_each_remote() {
// the remote
test_env.jj_cmd_ok(&workspace_root, &["new", "main", "-m=private 1"]);
test_env.jj_cmd_ok(&workspace_root, &["new", "-m=public 3"]);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "set", "main"]);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "set", "main", "-r@"]);
let (_, stderr) = test_env.jj_cmd_ok(&workspace_root, &["git", "push", "-b=main"]);
insta::assert_snapshot!(stderr, @r#"
Changes to push to origin:

View File

@ -30,9 +30,9 @@ fn set_up() -> (TestEnvironment, PathBuf) {
.join("git");
test_env.jj_cmd_ok(&origin_path, &["describe", "-m=description 1"]);
test_env.jj_cmd_ok(&origin_path, &["bookmark", "create", "bookmark1"]);
test_env.jj_cmd_ok(&origin_path, &["bookmark", "create", "-r@", "bookmark1"]);
test_env.jj_cmd_ok(&origin_path, &["new", "root()", "-m=description 2"]);
test_env.jj_cmd_ok(&origin_path, &["bookmark", "create", "bookmark2"]);
test_env.jj_cmd_ok(&origin_path, &["bookmark", "create", "-r@", "bookmark2"]);
test_env.jj_cmd_ok(&origin_path, &["git", "export"]);
test_env.jj_cmd_ok(
@ -92,8 +92,11 @@ fn test_git_push_current_bookmark(subprocess: bool) {
&["describe", "bookmark1", "-m", "modified bookmark1 commit"],
);
test_env.jj_cmd_ok(&workspace_root, &["new", "bookmark2"]);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "set", "bookmark2"]);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "create", "my-bookmark"]);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "set", "bookmark2", "-r@"]);
test_env.jj_cmd_ok(
&workspace_root,
&["bookmark", "create", "-r@", "my-bookmark"],
);
test_env.jj_cmd_ok(&workspace_root, &["describe", "-m", "foo"]);
// Check the setup
insta::allow_duplicates! {
@ -332,13 +335,13 @@ fn test_git_push_forward_unexpectedly_moved(subprocess: bool) {
let origin_path = test_env.env_root().join("origin");
test_env.jj_cmd_ok(&origin_path, &["new", "bookmark1", "-m=remote"]);
std::fs::write(origin_path.join("remote"), "remote").unwrap();
test_env.jj_cmd_ok(&origin_path, &["bookmark", "set", "bookmark1"]);
test_env.jj_cmd_ok(&origin_path, &["bookmark", "set", "bookmark1", "-r@"]);
test_env.jj_cmd_ok(&origin_path, &["git", "export"]);
// Move bookmark1 forward to another commit locally
test_env.jj_cmd_ok(&workspace_root, &["new", "bookmark1", "-m=local"]);
std::fs::write(workspace_root.join("local"), "local").unwrap();
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "set", "bookmark1"]);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "set", "bookmark1", "-r@"]);
// Pushing should fail
let stderr = test_env.jj_cmd_failure(&workspace_root, &["git", "push"]);
@ -364,7 +367,7 @@ fn test_git_push_sideways_unexpectedly_moved(subprocess: bool) {
let origin_path = test_env.env_root().join("origin");
test_env.jj_cmd_ok(&origin_path, &["new", "bookmark1", "-m=remote"]);
std::fs::write(origin_path.join("remote"), "remote").unwrap();
test_env.jj_cmd_ok(&origin_path, &["bookmark", "set", "bookmark1"]);
test_env.jj_cmd_ok(&origin_path, &["bookmark", "set", "bookmark1", "-r@"]);
insta::allow_duplicates! {
insta::assert_snapshot!(get_bookmark_output(&test_env, &origin_path), @r###"
bookmark1: vruxwmqv 80284bec remote
@ -380,7 +383,7 @@ fn test_git_push_sideways_unexpectedly_moved(subprocess: bool) {
std::fs::write(workspace_root.join("local"), "local").unwrap();
test_env.jj_cmd_ok(
&workspace_root,
&["bookmark", "set", "bookmark1", "--allow-backwards"],
&["bookmark", "set", "bookmark1", "--allow-backwards", "-r@"],
);
insta::allow_duplicates! {
insta::assert_snapshot!(get_bookmark_output(&test_env, &workspace_root), @r###"
@ -416,7 +419,7 @@ fn test_git_push_deletion_unexpectedly_moved(subprocess: bool) {
let origin_path = test_env.env_root().join("origin");
test_env.jj_cmd_ok(&origin_path, &["new", "bookmark1", "-m=remote"]);
std::fs::write(origin_path.join("remote"), "remote").unwrap();
test_env.jj_cmd_ok(&origin_path, &["bookmark", "set", "bookmark1"]);
test_env.jj_cmd_ok(&origin_path, &["bookmark", "set", "bookmark1", "-r@"]);
insta::allow_duplicates! {
insta::assert_snapshot!(get_bookmark_output(&test_env, &origin_path), @r###"
bookmark1: vruxwmqv 80284bec remote
@ -476,7 +479,7 @@ fn test_git_push_unexpectedly_deleted(subprocess: bool) {
std::fs::write(workspace_root.join("local"), "local").unwrap();
test_env.jj_cmd_ok(
&workspace_root,
&["bookmark", "set", "bookmark1", "--allow-backwards"],
&["bookmark", "set", "bookmark1", "--allow-backwards", "-r@"],
);
insta::allow_duplicates! {
insta::assert_snapshot!(get_bookmark_output(&test_env, &workspace_root), @r###"
@ -544,7 +547,7 @@ fn test_git_push_creation_unexpectedly_already_exists(subprocess: bool) {
// Create a new branh1
test_env.jj_cmd_ok(&workspace_root, &["new", "root()", "-m=new bookmark1"]);
std::fs::write(workspace_root.join("local"), "local").unwrap();
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "create", "bookmark1"]);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "create", "-r@", "bookmark1"]);
insta::allow_duplicates! {
insta::assert_snapshot!(get_bookmark_output(&test_env, &workspace_root), @r###"
bookmark1: yostqsxw cb17dcdc new bookmark1
@ -576,7 +579,7 @@ fn test_git_push_locally_created_and_rewritten(subprocess: bool) {
// Push locally-created bookmark
test_env.jj_cmd_ok(&workspace_root, &["new", "root()", "-mlocal 1"]);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "create", "my"]);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "create", "-r@", "my"]);
let (_stdout, stderr) = test_env.jj_cmd_ok(&workspace_root, &["git", "push"]);
insta::allow_duplicates! {
insta::assert_snapshot!(stderr, @r"
@ -640,9 +643,12 @@ fn test_git_push_multiple(subprocess: bool) {
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "delete", "bookmark1"]);
test_env.jj_cmd_ok(
&workspace_root,
&["bookmark", "set", "--allow-backwards", "bookmark2"],
&["bookmark", "set", "--allow-backwards", "bookmark2", "-r@"],
);
test_env.jj_cmd_ok(
&workspace_root,
&["bookmark", "create", "-r@", "my-bookmark"],
);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "create", "my-bookmark"]);
test_env.jj_cmd_ok(&workspace_root, &["describe", "-m", "foo"]);
// Check the setup
insta::allow_duplicates! {
@ -958,11 +964,20 @@ fn test_git_push_revisions(subprocess: bool) {
test_env.jj_cmd_ok(&workspace_root, &["describe", "-m", "foo"]);
std::fs::write(workspace_root.join("file"), "contents").unwrap();
test_env.jj_cmd_ok(&workspace_root, &["new", "-m", "bar"]);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "create", "bookmark-1"]);
test_env.jj_cmd_ok(
&workspace_root,
&["bookmark", "create", "-r@", "bookmark-1"],
);
std::fs::write(workspace_root.join("file"), "modified").unwrap();
test_env.jj_cmd_ok(&workspace_root, &["new", "-m", "baz"]);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "create", "bookmark-2a"]);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "create", "bookmark-2b"]);
test_env.jj_cmd_ok(
&workspace_root,
&["bookmark", "create", "-r@", "bookmark-2a"],
);
test_env.jj_cmd_ok(
&workspace_root,
&["bookmark", "create", "-r@", "bookmark-2b"],
);
std::fs::write(workspace_root.join("file"), "modified again").unwrap();
// Push an empty set
@ -1062,11 +1077,20 @@ fn test_git_push_mixed(subprocess: bool) {
test_env.jj_cmd_ok(&workspace_root, &["describe", "-m", "foo"]);
std::fs::write(workspace_root.join("file"), "contents").unwrap();
test_env.jj_cmd_ok(&workspace_root, &["new", "-m", "bar"]);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "create", "bookmark-1"]);
test_env.jj_cmd_ok(
&workspace_root,
&["bookmark", "create", "-r@", "bookmark-1"],
);
std::fs::write(workspace_root.join("file"), "modified").unwrap();
test_env.jj_cmd_ok(&workspace_root, &["new", "-m", "baz"]);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "create", "bookmark-2a"]);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "create", "bookmark-2b"]);
test_env.jj_cmd_ok(
&workspace_root,
&["bookmark", "create", "-r@", "bookmark-2a"],
);
test_env.jj_cmd_ok(
&workspace_root,
&["bookmark", "create", "-r@", "bookmark-2b"],
);
std::fs::write(workspace_root.join("file"), "modified again").unwrap();
// --allow-new is not implied for --bookmark=.. and -r=..
@ -1128,6 +1152,7 @@ fn test_git_push_existing_long_bookmark(subprocess: bool) {
&[
"bookmark",
"create",
"-r@",
"push-19b790168e73f7a73a98deae21e807c0",
],
);
@ -1171,7 +1196,10 @@ fn test_git_push_conflict(subprocess: bool) {
test_env.jj_cmd_ok(&workspace_root, &["commit", "-m", "second"]);
std::fs::write(workspace_root.join("file"), "third").unwrap();
test_env.jj_cmd_ok(&workspace_root, &["rebase", "-r", "@", "-d", "@--"]);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "create", "my-bookmark"]);
test_env.jj_cmd_ok(
&workspace_root,
&["bookmark", "create", "-r@", "my-bookmark"],
);
test_env.jj_cmd_ok(&workspace_root, &["describe", "-m", "third"]);
let stderr = test_env.jj_cmd_failure(&workspace_root, &["git", "push", "--all"]);
insta::allow_duplicates! {
@ -1189,7 +1217,10 @@ fn test_git_push_no_description(subprocess: bool) {
if !subprocess {
test_env.add_config("git.subprocess = false");
}
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "create", "my-bookmark"]);
test_env.jj_cmd_ok(
&workspace_root,
&["bookmark", "create", "-r@", "my-bookmark"],
);
test_env.jj_cmd_ok(&workspace_root, &["describe", "-m="]);
let stderr = test_env.jj_cmd_failure(
&workspace_root,
@ -1221,11 +1252,14 @@ fn test_git_push_no_description_in_immutable(subprocess: bool) {
if !subprocess {
test_env.add_config("git.subprocess = false");
}
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "create", "imm"]);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "create", "-r@", "imm"]);
test_env.jj_cmd_ok(&workspace_root, &["describe", "-m="]);
test_env.jj_cmd_ok(&workspace_root, &["new", "-m", "foo"]);
std::fs::write(workspace_root.join("file"), "contents").unwrap();
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "create", "my-bookmark"]);
test_env.jj_cmd_ok(
&workspace_root,
&["bookmark", "create", "-r@", "my-bookmark"],
);
let stderr = test_env.jj_cmd_failure(
&workspace_root,
@ -1282,7 +1316,7 @@ fn test_git_push_missing_author(subprocess: bool) {
.success();
};
run_without_var("JJ_USER", &["new", "root()", "-m=initial"]);
run_without_var("JJ_USER", &["bookmark", "create", "missing-name"]);
run_without_var("JJ_USER", &["bookmark", "create", "-r@", "missing-name"]);
let stderr = test_env.jj_cmd_failure(
&workspace_root,
&["git", "push", "--allow-new", "--bookmark", "missing-name"],
@ -1294,7 +1328,7 @@ fn test_git_push_missing_author(subprocess: bool) {
");
}
run_without_var("JJ_EMAIL", &["new", "root()", "-m=initial"]);
run_without_var("JJ_EMAIL", &["bookmark", "create", "missing-email"]);
run_without_var("JJ_EMAIL", &["bookmark", "create", "-r@", "missing-email"]);
let stderr = test_env.jj_cmd_failure(
&workspace_root,
&["git", "push", "--allow-new", "--bookmark=missing-email"],
@ -1323,10 +1357,13 @@ fn test_git_push_missing_author_in_immutable(subprocess: bool) {
};
run_without_var("JJ_USER", &["new", "root()", "-m=no author name"]);
run_without_var("JJ_EMAIL", &["new", "-m=no author email"]);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "create", "imm"]);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "create", "-r@", "imm"]);
test_env.jj_cmd_ok(&workspace_root, &["new", "-m", "foo"]);
std::fs::write(workspace_root.join("file"), "contents").unwrap();
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "create", "my-bookmark"]);
test_env.jj_cmd_ok(
&workspace_root,
&["bookmark", "create", "-r@", "my-bookmark"],
);
let stderr = test_env.jj_cmd_failure(
&workspace_root,
@ -1382,7 +1419,10 @@ fn test_git_push_missing_committer(subprocess: bool) {
.assert()
.success();
};
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "create", "missing-name"]);
test_env.jj_cmd_ok(
&workspace_root,
&["bookmark", "create", "-r@", "missing-name"],
);
run_without_var("JJ_USER", &["describe", "-m=no committer name"]);
let stderr = test_env.jj_cmd_failure(
&workspace_root,
@ -1395,7 +1435,10 @@ fn test_git_push_missing_committer(subprocess: bool) {
");
}
test_env.jj_cmd_ok(&workspace_root, &["new", "root()"]);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "create", "missing-email"]);
test_env.jj_cmd_ok(
&workspace_root,
&["bookmark", "create", "-r@", "missing-email"],
);
run_without_var("JJ_EMAIL", &["describe", "-m=no committer email"]);
let stderr = test_env.jj_cmd_failure(
&workspace_root,
@ -1440,10 +1483,13 @@ fn test_git_push_missing_committer_in_immutable(subprocess: bool) {
run_without_var("JJ_USER", &["describe", "-m=no committer name"]);
test_env.jj_cmd_ok(&workspace_root, &["new"]);
run_without_var("JJ_EMAIL", &["describe", "-m=no committer email"]);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "create", "imm"]);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "create", "-r@", "imm"]);
test_env.jj_cmd_ok(&workspace_root, &["new", "-m", "foo"]);
std::fs::write(workspace_root.join("file"), "contents").unwrap();
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "create", "my-bookmark"]);
test_env.jj_cmd_ok(
&workspace_root,
&["bookmark", "create", "-r@", "my-bookmark"],
);
let stderr = test_env.jj_cmd_failure(
&workspace_root,
@ -1549,7 +1595,7 @@ fn test_git_push_conflicting_bookmarks(subprocess: bool) {
.unwrap();
test_env.jj_cmd_ok(&workspace_root, &["git", "import"]);
test_env.jj_cmd_ok(&workspace_root, &["new", "root()", "-m=description 3"]);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "create", "bookmark2"]);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "create", "-r@", "bookmark2"]);
test_env.jj_cmd_ok(&workspace_root, &["git", "fetch"]);
insta::allow_duplicates! {
insta::assert_snapshot!(get_bookmark_output(&test_env, &workspace_root), @r###"
@ -1564,7 +1610,7 @@ fn test_git_push_conflicting_bookmarks(subprocess: bool) {
let bump_bookmark1 = || {
test_env.jj_cmd_ok(&workspace_root, &["new", "bookmark1", "-m=bump"]);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "set", "bookmark1"]);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "set", "bookmark1", "-r@"]);
};
// Conflicting bookmark at @
@ -1661,14 +1707,14 @@ fn test_git_push_tracked_vs_all(subprocess: bool) {
test_env.add_config("git.subprocess = false");
}
test_env.jj_cmd_ok(&workspace_root, &["new", "bookmark1", "-mmoved bookmark1"]);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "set", "bookmark1"]);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "set", "bookmark1", "-r@"]);
test_env.jj_cmd_ok(&workspace_root, &["new", "bookmark2", "-mmoved bookmark2"]);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "delete", "bookmark2"]);
test_env.jj_cmd_ok(
&workspace_root,
&["bookmark", "untrack", "bookmark1@origin"],
);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "create", "bookmark3"]);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "create", "-r@", "bookmark3"]);
insta::allow_duplicates! {
insta::assert_snapshot!(get_bookmark_output(&test_env, &workspace_root), @r###"
bookmark1: vruxwmqv db059e3f (empty) moved bookmark1
@ -1749,7 +1795,7 @@ fn test_git_push_moved_forward_untracked(subprocess: bool) {
}
test_env.jj_cmd_ok(&workspace_root, &["new", "bookmark1", "-mmoved bookmark1"]);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "set", "bookmark1"]);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "set", "bookmark1", "-r@"]);
test_env.jj_cmd_ok(
&workspace_root,
&["bookmark", "untrack", "bookmark1@origin"],
@ -1775,7 +1821,7 @@ fn test_git_push_moved_sideways_untracked(subprocess: bool) {
test_env.jj_cmd_ok(&workspace_root, &["new", "root()", "-mmoved bookmark1"]);
test_env.jj_cmd_ok(
&workspace_root,
&["bookmark", "set", "--allow-backwards", "bookmark1"],
&["bookmark", "set", "--allow-backwards", "bookmark1", "-r@"],
);
test_env.jj_cmd_ok(
&workspace_root,
@ -1837,7 +1883,7 @@ fn test_git_push_sign_on_push() {
&["new", "bookmark2", "-m", "commit to be signed 1"],
);
test_env.jj_cmd_ok(&workspace_root, &["new", "-m", "commit to be signed 2"]);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "set", "bookmark2"]);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "set", "bookmark2", "-r@"]);
test_env.jj_cmd_ok(
&workspace_root,
&["new", "-m", "commit which should not be signed 1"],

View File

@ -217,7 +217,7 @@ fn test_git_remote_named_git() {
.remote("git", "http://example.com/repo/repo")
.unwrap();
test_env.jj_cmd_ok(&repo_path, &["git", "init", "--git-repo=."]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "main"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "main"]);
// The remote can be renamed.
let (stdout, stderr) =

View File

@ -104,7 +104,7 @@ fn test_gitignores_ignored_file_in_target_commit() {
// Create a commit with file "ignored" in it
std::fs::write(workspace_root.join("ignored"), "committed contents\n").unwrap();
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "create", "with-file"]);
test_env.jj_cmd_ok(&workspace_root, &["bookmark", "create", "-r@", "with-file"]);
let target_commit_id = test_env.jj_cmd_success(
&workspace_root,
&["log", "--no-graph", "-T=commit_id", "-r=@"],

View File

@ -95,9 +95,9 @@ fn test_no_subcommand() {
assert_eq!(stdout, test_env.jj_cmd_success(&repo_path, &["log"]));
// Command argument that looks like a command name.
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "help"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "log"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "show"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "help"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "log"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "show"]);
// TODO: test_env.jj_cmd_ok(&repo_path, &["-r", "help"])
insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["-r", "log"]), @r###"
@ qpvuntsm test.user@example.com 2001-02-03 08:05:07 help log show 230dd059

View File

@ -23,7 +23,7 @@ fn test_rewrite_immutable_generic() {
test_env.jj_cmd_ok(&repo_path, &["describe", "-m=a"]);
test_env.jj_cmd_ok(&repo_path, &["new", "-m=b"]);
std::fs::write(repo_path.join("file"), "b").unwrap();
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "main"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "main"]);
test_env.jj_cmd_ok(&repo_path, &["new", "main-", "-m=c"]);
std::fs::write(repo_path.join("file"), "c").unwrap();
let stdout = test_env.jj_cmd_success(&repo_path, &["log"]);
@ -111,10 +111,10 @@ fn test_rewrite_immutable_generic() {
fn test_new_wc_commit_when_wc_immutable() {
let test_env = TestEnvironment::default();
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init"]);
test_env.jj_cmd_ok(test_env.env_root(), &["bookmark", "create", "main"]);
test_env.jj_cmd_ok(test_env.env_root(), &["bookmark", "create", "-r@", "main"]);
test_env.add_config(r#"revset-aliases."immutable_heads()" = "main""#);
test_env.jj_cmd_ok(test_env.env_root(), &["new", "-m=a"]);
let (_, stderr) = test_env.jj_cmd_ok(test_env.env_root(), &["bookmark", "set", "main"]);
let (_, stderr) = test_env.jj_cmd_ok(test_env.env_root(), &["bookmark", "set", "main", "-r@"]);
insta::assert_snapshot!(stderr, @r###"
Moved 1 bookmarks to kkmpptxz a164195b main | (empty) a
Warning: The working-copy commit in workspace 'default' became immutable, so a new commit has been created on top of it.
@ -127,7 +127,7 @@ fn test_new_wc_commit_when_wc_immutable() {
fn test_immutable_heads_set_to_working_copy() {
let test_env = TestEnvironment::default();
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init"]);
test_env.jj_cmd_ok(test_env.env_root(), &["bookmark", "create", "main"]);
test_env.jj_cmd_ok(test_env.env_root(), &["bookmark", "create", "-r@", "main"]);
test_env.add_config(r#"revset-aliases."immutable_heads()" = "@""#);
let (_, stderr) = test_env.jj_cmd_ok(test_env.env_root(), &["new", "-m=a"]);
insta::assert_snapshot!(stderr, @r###"
@ -142,13 +142,13 @@ fn test_new_wc_commit_when_wc_immutable_multi_workspace() {
let test_env = TestEnvironment::default();
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
let repo_path = test_env.env_root().join("repo");
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "main"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "main"]);
test_env.add_config(r#"revset-aliases."immutable_heads()" = "main""#);
test_env.jj_cmd_ok(&repo_path, &["new", "-m=a"]);
test_env.jj_cmd_ok(&repo_path, &["workspace", "add", "../workspace1"]);
let workspace1_envroot = test_env.env_root().join("workspace1");
test_env.jj_cmd_ok(&workspace1_envroot, &["edit", "default@"]);
let (_, stderr) = test_env.jj_cmd_ok(&repo_path, &["bookmark", "set", "main"]);
let (_, stderr) = test_env.jj_cmd_ok(&repo_path, &["bookmark", "set", "main", "-r@"]);
insta::assert_snapshot!(stderr, @r###"
Moved 1 bookmarks to kkmpptxz 7796c4df main | (empty) a
Warning: The working-copy commit in workspace 'default' became immutable, so a new commit has been created on top of it.
@ -184,7 +184,7 @@ fn test_rewrite_immutable_commands() {
// Create another file to make sure the merge commit isn't empty (to satisfy `jj
// split`) and still has a conflict (to satisfy `jj resolve`).
std::fs::write(repo_path.join("file2"), "merged").unwrap();
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "main"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "main"]);
test_env.jj_cmd_ok(&repo_path, &["new", "description(b)"]);
std::fs::write(repo_path.join("file"), "w").unwrap();
test_env.add_config(r#"revset-aliases."immutable_heads()" = "main""#);

View File

@ -23,13 +23,13 @@ fn test_interdiff_basic() {
std::fs::write(repo_path.join("file1"), "foo\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["new"]);
std::fs::write(repo_path.join("file2"), "foo\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "left"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "left"]);
test_env.jj_cmd_ok(&repo_path, &["new", "root()"]);
std::fs::write(repo_path.join("file3"), "foo\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["new"]);
std::fs::write(repo_path.join("file2"), "foo\nbar\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "right"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "right"]);
// implicit --to
let stdout = test_env.jj_cmd_success(&repo_path, &["interdiff", "--from", "left"]);
@ -87,7 +87,7 @@ fn test_interdiff_paths() {
test_env.jj_cmd_ok(&repo_path, &["new"]);
std::fs::write(repo_path.join("file1"), "bar\n").unwrap();
std::fs::write(repo_path.join("file2"), "bar\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "left"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "left"]);
test_env.jj_cmd_ok(&repo_path, &["new", "root()"]);
std::fs::write(repo_path.join("file1"), "foo\n").unwrap();
@ -95,7 +95,7 @@ fn test_interdiff_paths() {
test_env.jj_cmd_ok(&repo_path, &["new"]);
std::fs::write(repo_path.join("file1"), "baz\n").unwrap();
std::fs::write(repo_path.join("file2"), "baz\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "right"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "right"]);
let stdout = test_env.jj_cmd_success(
&repo_path,
@ -135,13 +135,13 @@ fn test_interdiff_conflicting() {
std::fs::write(repo_path.join("file"), "foo\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["new"]);
std::fs::write(repo_path.join("file"), "bar\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "left"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "left"]);
test_env.jj_cmd_ok(&repo_path, &["new", "root()"]);
std::fs::write(repo_path.join("file"), "abc\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["new"]);
std::fs::write(repo_path.join("file"), "def\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "right"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "right"]);
let stdout = test_env.jj_cmd_success(
&repo_path,

View File

@ -353,7 +353,7 @@ fn test_log_shortest_accessors() {
std::fs::write(repo_path.join("file"), "original file\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["describe", "-m", "initial"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "c", "original"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "c", "-r@", "original"]);
insta::assert_snapshot!(
render("original", r#"format_id(change_id) ++ " " ++ format_id(commit_id)"#),
@"q[pvuntsmwlqt] e[0e22b9fae75]");
@ -516,7 +516,7 @@ fn test_log_prefix_highlight_styled() {
std::fs::write(repo_path.join("file"), "original file\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["describe", "-m", "initial"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "c", "original"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "c", "-r@", "original"]);
insta::assert_snapshot!(
test_env.jj_cmd_success(&repo_path, &["log", "-r", "original", "-T", &prefix_format(Some(12))]),
@r###"
@ -650,7 +650,7 @@ fn test_log_prefix_highlight_counts_hidden_commits() {
std::fs::write(repo_path.join("file"), "original file\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["describe", "-m", "initial"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "c", "original"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "c", "-r@", "original"]);
insta::assert_snapshot!(
test_env.jj_cmd_success(&repo_path, &["log", "-r", "all()", "-T", prefix_format]),
@r###"
@ -1108,7 +1108,7 @@ fn test_multiple_revsets() {
let repo_path = test_env.env_root().join("repo");
for name in ["foo", "bar", "baz"] {
test_env.jj_cmd_ok(&repo_path, &["new", "-m", name]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", name]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", name]);
}
// Default revset should be overridden if one or more -r options are specified.

View File

@ -69,7 +69,7 @@ fn test_new_merge() {
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
let repo_path = test_env.env_root().join("repo");
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "main"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "main"]);
test_env.jj_cmd_ok(&repo_path, &["describe", "-m", "add file1"]);
std::fs::write(repo_path.join("file1"), "a").unwrap();
test_env.jj_cmd_ok(&repo_path, &["new", "root()", "-m", "add file2"]);
@ -608,7 +608,7 @@ fn test_new_conflicting_bookmarks() {
test_env.jj_cmd_ok(&repo_path, &["describe", "-m", "one"]);
test_env.jj_cmd_ok(&repo_path, &["new", "-m", "two", "@-"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "foo"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "foo"]);
test_env.jj_cmd_ok(
&repo_path,
&[
@ -671,19 +671,19 @@ fn test_new_error_revision_does_not_exist() {
}
fn setup_before_insertion(test_env: &TestEnvironment, repo_path: &Path) {
test_env.jj_cmd_ok(repo_path, &["bookmark", "create", "A"]);
test_env.jj_cmd_ok(repo_path, &["bookmark", "create", "-r@", "A"]);
test_env.jj_cmd_ok(repo_path, &["commit", "-m", "A"]);
test_env.jj_cmd_ok(repo_path, &["bookmark", "create", "B"]);
test_env.jj_cmd_ok(repo_path, &["bookmark", "create", "-r@", "B"]);
test_env.jj_cmd_ok(repo_path, &["commit", "-m", "B"]);
test_env.jj_cmd_ok(repo_path, &["bookmark", "create", "C"]);
test_env.jj_cmd_ok(repo_path, &["bookmark", "create", "-r@", "C"]);
test_env.jj_cmd_ok(repo_path, &["describe", "-m", "C"]);
test_env.jj_cmd_ok(repo_path, &["new", "-m", "D", "root()"]);
test_env.jj_cmd_ok(repo_path, &["bookmark", "create", "D"]);
test_env.jj_cmd_ok(repo_path, &["bookmark", "create", "-r@", "D"]);
test_env.jj_cmd_ok(repo_path, &["new", "-m", "E", "root()"]);
test_env.jj_cmd_ok(repo_path, &["bookmark", "create", "E"]);
test_env.jj_cmd_ok(repo_path, &["bookmark", "create", "-r@", "E"]);
// Any number of -r's is ignored
test_env.jj_cmd_ok(repo_path, &["new", "-m", "F", "-r", "D", "-r", "E"]);
test_env.jj_cmd_ok(repo_path, &["bookmark", "create", "F"]);
test_env.jj_cmd_ok(repo_path, &["bookmark", "create", "-r@", "F"]);
}
fn get_log_output(test_env: &TestEnvironment, repo_path: &Path) -> String {

View File

@ -432,9 +432,9 @@ fn test_prev_on_merge_commit() {
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
let repo_path = test_env.env_root().join("repo");
test_env.jj_cmd_ok(&repo_path, &["desc", "-m", "first"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "c", "left"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "c", "-r@", "left"]);
test_env.jj_cmd_ok(&repo_path, &["new", "root()", "-m", "second"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "c", "right"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "c", "-r@", "right"]);
test_env.jj_cmd_ok(&repo_path, &["new", "left", "right"]);
// Check that the graph looks the way we expect.

View File

@ -25,7 +25,7 @@ fn create_commit(test_env: &TestEnvironment, repo_path: &Path, name: &str, paren
test_env.jj_cmd_ok(repo_path, &args);
}
std::fs::write(repo_path.join(name), format!("{name}\n")).unwrap();
test_env.jj_cmd_ok(repo_path, &["bookmark", "create", name]);
test_env.jj_cmd_ok(repo_path, &["bookmark", "create", "-r@", name]);
}
#[test]
@ -648,13 +648,13 @@ fn test_rebase_revision_onto_descendant() {
// Now, let's rebase onto the descendant merge
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["op", "restore", &setup_opid]);
insta::assert_snapshot!(stdout, @"");
insta::assert_snapshot!(stderr, @r#"
Restored to operation: cc1a7e3419ad (2001-02-03 08:05:15) create bookmark merge pointing to commit b05964d109522cd06e48f1a2661e1a0f58be0984
insta::assert_snapshot!(stderr, @r"
Restored to operation: 8370ca29327a (2001-02-03 08:05:15) create bookmark merge pointing to commit b05964d109522cd06e48f1a2661e1a0f58be0984
Working copy now at: vruxwmqv b05964d1 merge | merge
Parent commit : royxmykx cea87a87 b | b
Parent commit : zsuskuln 2c5b7858 a | a
Added 1 files, modified 0 files, removed 0 files
"#);
");
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["rebase", "-r", "base", "-d", "merge"]);
insta::assert_snapshot!(stdout, @"");
insta::assert_snapshot!(stderr, @r###"
@ -906,7 +906,7 @@ fn test_rebase_error_revision_does_not_exist() {
let repo_path = test_env.env_root().join("repo");
test_env.jj_cmd_ok(&repo_path, &["describe", "-m", "one"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "b-one"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "b-one"]);
test_env.jj_cmd_ok(&repo_path, &["new", "-r", "@-", "-m", "two"]);
let stderr = test_env.jj_cmd_failure(&repo_path, &["rebase", "-b", "b-one", "-d", "this"]);
@ -2645,7 +2645,7 @@ fn test_rebase_skip_emptied_descendants() {
create_commit(&test_env, &repo_path, "b", &["a"]);
test_env.jj_cmd_ok(&repo_path, &["new", "a", "-m", "c (will become empty)"]);
test_env.jj_cmd_ok(&repo_path, &["restore", "--from=b"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "c"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "c"]);
test_env.jj_cmd_ok(&repo_path, &["new", "-m", "already empty"]);
test_env.jj_cmd_ok(&repo_path, &["new", "-m", "also already empty"]);

View File

@ -35,7 +35,7 @@ fn create_commit(
for (name, content) in files {
std::fs::write(repo_path.join(name), content).unwrap();
}
test_env.jj_cmd_ok(repo_path, &["bookmark", "create", name]);
test_env.jj_cmd_ok(repo_path, &["bookmark", "create", "-r@", name]);
}
fn get_log_output(test_env: &TestEnvironment, repo_path: &Path) -> String {

View File

@ -598,7 +598,7 @@ fn create_commit(
for (name, content) in files {
std::fs::write(repo_path.join(name), content).unwrap();
}
test_env.jj_cmd_ok(repo_path, &["bookmark", "create", name]);
test_env.jj_cmd_ok(repo_path, &["bookmark", "create", "-r@", name]);
}
fn get_log_output(test_env: &TestEnvironment, repo_path: &Path) -> String {

View File

@ -33,7 +33,7 @@ fn create_commit(test_env: &TestEnvironment, repo_path: &Path, name: &str, paren
test_env.jj_cmd_ok(repo_path, &args);
std::fs::write(repo_path.join(name), format!("{name}\n")).unwrap();
test_env.jj_cmd_ok(repo_path, &["bookmark", "create", name]);
test_env.jj_cmd_ok(repo_path, &["bookmark", "create", "-r@", name]);
}
#[test]

View File

@ -228,7 +228,10 @@ fn test_split_with_default_description() {
// Create a bookmark pointing to the commit. It will be moved to the second
// commit after the split.
test_env.jj_cmd_ok(&workspace_path, &["bookmark", "create", "test_bookmark"]);
test_env.jj_cmd_ok(
&workspace_path,
&["bookmark", "create", "-r@", "test_bookmark"],
);
let edit_script = test_env.set_up_fake_editor();
std::fs::write(
@ -336,7 +339,10 @@ fn test_split_siblings_no_descendants() {
// Create a bookmark pointing to the commit. It will be moved to the second
// commit after the split.
test_env.jj_cmd_ok(&workspace_path, &["bookmark", "create", "test_bookmark"]);
test_env.jj_cmd_ok(
&workspace_path,
&["bookmark", "create", "-r@", "test_bookmark"],
);
insta::assert_snapshot!(get_log_output(&test_env, &workspace_path), @r###"
@ qpvuntsmwlqt false test_bookmark
zzzzzzzzzzzz true

View File

@ -23,13 +23,13 @@ fn test_squash() {
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
let repo_path = test_env.env_root().join("repo");
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "a"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "a"]);
std::fs::write(repo_path.join("file1"), "a\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["new"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "b"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "b"]);
std::fs::write(repo_path.join("file1"), "b\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["new"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "c"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "c"]);
std::fs::write(repo_path.join("file1"), "c\n").unwrap();
// Test the setup
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
@ -85,10 +85,10 @@ fn test_squash() {
test_env.jj_cmd_ok(&repo_path, &["undo"]);
test_env.jj_cmd_ok(&repo_path, &["edit", "b"]);
test_env.jj_cmd_ok(&repo_path, &["new"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "d"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "d"]);
std::fs::write(repo_path.join("file2"), "d\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["new", "c", "d"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "e"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "e"]);
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
@ 41219719ab5f e (empty)
@ -137,15 +137,15 @@ fn test_squash_partial() {
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
let repo_path = test_env.env_root().join("repo");
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "a"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "a"]);
std::fs::write(repo_path.join("file1"), "a\n").unwrap();
std::fs::write(repo_path.join("file2"), "a\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["new"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "b"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "b"]);
std::fs::write(repo_path.join("file1"), "b\n").unwrap();
std::fs::write(repo_path.join("file2"), "b\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["new"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "c"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "c"]);
std::fs::write(repo_path.join("file1"), "c\n").unwrap();
std::fs::write(repo_path.join("file2"), "c\n").unwrap();
// Test the setup
@ -283,13 +283,13 @@ fn test_squash_keep_emptied() {
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
let repo_path = test_env.env_root().join("repo");
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "a"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "a"]);
std::fs::write(repo_path.join("file1"), "a\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["new"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "b"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "b"]);
std::fs::write(repo_path.join("file1"), "b\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["new"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "c"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "c"]);
std::fs::write(repo_path.join("file1"), "c\n").unwrap();
// Test the setup
@ -337,25 +337,25 @@ fn test_squash_from_to() {
//
// When moving changes between e.g. C and F, we should not get unrelated changes
// from B and D.
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "a"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "a"]);
std::fs::write(repo_path.join("file1"), "a\n").unwrap();
std::fs::write(repo_path.join("file2"), "a\n").unwrap();
std::fs::write(repo_path.join("file3"), "a\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["new"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "b"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "b"]);
std::fs::write(repo_path.join("file3"), "b\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["new"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "c"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "c"]);
std::fs::write(repo_path.join("file1"), "c\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["edit", "a"]);
test_env.jj_cmd_ok(&repo_path, &["new"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "d"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "d"]);
std::fs::write(repo_path.join("file3"), "d\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["new"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "e"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "e"]);
std::fs::write(repo_path.join("file2"), "e\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["new"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "f"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "f"]);
std::fs::write(repo_path.join("file2"), "f\n").unwrap();
// Test the setup
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
@ -469,20 +469,20 @@ fn test_squash_from_to_partial() {
// D B
// |/
// A
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "a"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "a"]);
std::fs::write(repo_path.join("file1"), "a\n").unwrap();
std::fs::write(repo_path.join("file2"), "a\n").unwrap();
std::fs::write(repo_path.join("file3"), "a\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["new"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "b"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "b"]);
std::fs::write(repo_path.join("file3"), "b\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["new"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "c"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "c"]);
std::fs::write(repo_path.join("file1"), "c\n").unwrap();
std::fs::write(repo_path.join("file2"), "c\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["edit", "a"]);
test_env.jj_cmd_ok(&repo_path, &["new"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "d"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "d"]);
std::fs::write(repo_path.join("file3"), "d\n").unwrap();
// Test the setup
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
@ -651,22 +651,22 @@ fn test_squash_from_multiple() {
// \|/
// A
let file = repo_path.join("file");
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "a"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "a"]);
std::fs::write(&file, "a\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["new"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "b"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "b"]);
std::fs::write(&file, "b\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["new", "@-"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "c"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "c"]);
std::fs::write(&file, "c\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["new", "@-"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "d"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "d"]);
std::fs::write(&file, "d\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["new", "all:visible_heads()"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "e"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "e"]);
std::fs::write(&file, "e\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["new"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "f"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "f"]);
std::fs::write(&file, "f\n").unwrap();
// Test the setup
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
@ -770,27 +770,27 @@ fn test_squash_from_multiple_partial() {
// A
let file1 = repo_path.join("file1");
let file2 = repo_path.join("file2");
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "a"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "a"]);
std::fs::write(&file1, "a\n").unwrap();
std::fs::write(&file2, "a\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["new"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "b"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "b"]);
std::fs::write(&file1, "b\n").unwrap();
std::fs::write(&file2, "b\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["new", "@-"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "c"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "c"]);
std::fs::write(&file1, "c\n").unwrap();
std::fs::write(&file2, "c\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["new", "@-"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "d"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "d"]);
std::fs::write(&file1, "d\n").unwrap();
std::fs::write(&file2, "d\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["new", "all:visible_heads()"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "e"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "e"]);
std::fs::write(&file1, "e\n").unwrap();
std::fs::write(&file2, "e\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["new"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "f"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "f"]);
std::fs::write(&file1, "f\n").unwrap();
std::fs::write(&file2, "f\n").unwrap();
// Test the setup

View File

@ -33,7 +33,7 @@ fn create_commit(
for (name, content) in files {
std::fs::write(repo_path.join(name), content).unwrap();
}
test_env.jj_cmd_ok(repo_path, &["bookmark", "create", name]);
test_env.jj_cmd_ok(repo_path, &["bookmark", "create", "-r@", name]);
}
#[test]
@ -77,7 +77,7 @@ fn test_status_merge() {
std::fs::write(repo_path.join("file"), "base").unwrap();
test_env.jj_cmd_ok(&repo_path, &["new", "-m=left"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "left"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "left"]);
test_env.jj_cmd_ok(&repo_path, &["new", "@-", "-m=right"]);
std::fs::write(repo_path.join("file"), "right").unwrap();
test_env.jj_cmd_ok(&repo_path, &["new", "left", "@"]);

View File

@ -38,11 +38,11 @@ fn test_tag_list() {
};
test_env.jj_cmd_ok(&repo_path, &["new", "root()", "-mcommit1"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "bookmark1"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "bookmark1"]);
test_env.jj_cmd_ok(&repo_path, &["new", "root()", "-mcommit2"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "bookmark2"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "bookmark2"]);
test_env.jj_cmd_ok(&repo_path, &["new", "root()", "-mcommit3"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "bookmark3"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "bookmark3"]);
test_env.jj_cmd_ok(&repo_path, &["git", "export"]);
copy_ref("refs/heads/bookmark1", "test_tag");

View File

@ -57,7 +57,7 @@ fn test_git_push_undo() {
let repo_path = test_env.env_root().join("repo");
test_env.advance_test_rng_seed_to_multiple_of(100_000);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "main"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "main"]);
test_env.jj_cmd_ok(&repo_path, &["describe", "-m", "AA"]);
test_env.jj_cmd_ok(&repo_path, &["git", "push", "--allow-new"]);
test_env.advance_test_rng_seed_to_multiple_of(100_000);
@ -130,7 +130,7 @@ fn test_git_push_undo_with_import() {
let repo_path = test_env.env_root().join("repo");
test_env.advance_test_rng_seed_to_multiple_of(100_000);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "main"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "main"]);
test_env.jj_cmd_ok(&repo_path, &["describe", "-m", "AA"]);
test_env.jj_cmd_ok(&repo_path, &["git", "push", "--allow-new"]);
test_env.advance_test_rng_seed_to_multiple_of(100_000);
@ -211,7 +211,7 @@ fn test_git_push_undo_colocated() {
test_env.jj_cmd_ok(&repo_path, &["git", "init", "--git-repo=."]);
test_env.advance_test_rng_seed_to_multiple_of(100_000);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "main"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "main"]);
test_env.jj_cmd_ok(&repo_path, &["describe", "-m", "AA"]);
test_env.jj_cmd_ok(&repo_path, &["git", "push", "--allow-new"]);
test_env.advance_test_rng_seed_to_multiple_of(100_000);
@ -291,7 +291,7 @@ fn test_git_push_undo_repo_only() {
let repo_path = test_env.env_root().join("repo");
test_env.advance_test_rng_seed_to_multiple_of(100_000);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "main"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "main"]);
test_env.jj_cmd_ok(&repo_path, &["describe", "-m", "AA"]);
test_env.jj_cmd_ok(&repo_path, &["git", "push", "--allow-new"]);
insta::assert_snapshot!(get_bookmark_output(&test_env, &repo_path), @r###"
@ -336,7 +336,10 @@ fn test_bookmark_track_untrack_undo() {
let repo_path = test_env.env_root().join("repo");
test_env.jj_cmd_ok(&repo_path, &["describe", "-mcommit"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "feature1", "feature2"]);
test_env.jj_cmd_ok(
&repo_path,
&["bookmark", "create", "-r@", "feature1", "feature2"],
);
test_env.jj_cmd_ok(&repo_path, &["git", "push", "--allow-new"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "delete", "feature2"]);
insta::assert_snapshot!(get_bookmark_output(&test_env, &repo_path), @r###"

View File

@ -23,13 +23,13 @@ fn test_unsquash() {
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
let repo_path = test_env.env_root().join("repo");
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "a"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "a"]);
std::fs::write(repo_path.join("file1"), "a\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["new"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "b"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "b"]);
std::fs::write(repo_path.join("file1"), "b\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["new"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "c"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "c"]);
std::fs::write(repo_path.join("file1"), "c\n").unwrap();
// Test the setup
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
@ -88,10 +88,10 @@ fn test_unsquash() {
test_env.jj_cmd_ok(&repo_path, &["undo"]);
test_env.jj_cmd_ok(&repo_path, &["edit", "b"]);
test_env.jj_cmd_ok(&repo_path, &["new"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "d"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "d"]);
std::fs::write(repo_path.join("file2"), "d\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["new", "-m", "merge", "c", "d"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "e"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "e"]);
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
@ b780e7469252 e
@ -143,15 +143,15 @@ fn test_unsquash_partial() {
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
let repo_path = test_env.env_root().join("repo");
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "a"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "a"]);
std::fs::write(repo_path.join("file1"), "a\n").unwrap();
std::fs::write(repo_path.join("file2"), "a\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["new"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "b"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "b"]);
std::fs::write(repo_path.join("file1"), "b\n").unwrap();
std::fs::write(repo_path.join("file2"), "b\n").unwrap();
test_env.jj_cmd_ok(&repo_path, &["new"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "c"]);
test_env.jj_cmd_ok(&repo_path, &["bookmark", "create", "-r@", "c"]);
std::fs::write(repo_path.join("file1"), "c\n").unwrap();
std::fs::write(repo_path.join("file2"), "c\n").unwrap();
// Test the setup

View File

@ -231,8 +231,8 @@ The use of bookmarks is frequent in some workflows, for example, when
interacting with Git repositories containing branches. To this end,
one-letter shortcuts have been implemented, both for the `jj bookmark`
command itself through an alias (as `jj b`), and for its subcommands.
For example, `jj bookmark create BOOKMARK-NAME` can be abbreviated as
`jj b c BOOKMARK-NAME`.
For example, `jj bookmark create BOOKMARK-NAME -r@` can be abbreviated as
`jj b c BOOKMARK-NAME -r@`.
[colocated-repos]: git-compatibility.md#co-located-jujutsugit-repos
[design]: design/tracking-branches.md