forked from mirrors/jj
cli: add "branch list --all" option to include all remote branches
This will be the option to include non-tracking remote branches. We could add more fine-grained filtering flags, but I think --all is good enough and easier to remember. This patch also updates many of the test outputs to include synchronized remote branches. I think verbose outputs will help catch future bugs.
This commit is contained in:
parent
872265a220
commit
12b879dc8f
8 changed files with 178 additions and 26 deletions
|
@ -64,13 +64,20 @@ pub struct BranchDeleteArgs {
|
|||
|
||||
/// List branches and their targets
|
||||
///
|
||||
/// A tracking remote branch will be included only if its target is different
|
||||
/// from the local target. For a conflicted branch (both local and remote), old
|
||||
/// target revisions are preceded by a "-" and new target revisions are preceded
|
||||
/// by a "+". For information about branches, see
|
||||
/// By default, a tracking remote branch will be included only if its target is
|
||||
/// different from the local target. For a conflicted branch (both local and
|
||||
/// remote), old target revisions are preceded by a "-" and new target revisions
|
||||
/// are preceded by a "+".
|
||||
///
|
||||
/// For information about branches, see
|
||||
/// https://github.com/martinvonz/jj/blob/main/docs/branches.md.
|
||||
#[derive(clap::Args, Clone, Debug)]
|
||||
pub struct BranchListArgs {
|
||||
/// Show all tracking and non-tracking remote branches including the ones
|
||||
/// whose targets are synchronized with the local branches.
|
||||
#[arg(long, short, conflicts_with = "revisions")]
|
||||
all: bool,
|
||||
|
||||
/// Show branches whose local targets are in the given revisions.
|
||||
///
|
||||
/// Note that `-r deleted_branch` will not work since `deleted_branch`
|
||||
|
@ -518,13 +525,14 @@ fn cmd_branch_list(
|
|||
}
|
||||
|
||||
for &(remote, remote_ref) in &tracking_remote_refs {
|
||||
if remote_ref.target == *branch_target.local_target {
|
||||
let synced = remote_ref.target == *branch_target.local_target;
|
||||
if !args.all && synced {
|
||||
continue;
|
||||
}
|
||||
write!(formatter, " ")?;
|
||||
write!(formatter.labeled("branch"), "@{remote}")?;
|
||||
let local_target = branch_target.local_target;
|
||||
if local_target.is_present() {
|
||||
if local_target.is_present() && !synced {
|
||||
let remote_added_ids = remote_ref.target.added_ids().cloned().collect_vec();
|
||||
let local_added_ids = local_target.added_ids().cloned().collect_vec();
|
||||
let remote_ahead_count =
|
||||
|
|
|
@ -209,6 +209,7 @@ fn test_branch_delete_glob() {
|
|||
// The deleted branches are still there
|
||||
insta::assert_snapshot!(get_branch_output(&test_env, &repo_path), @r###"
|
||||
bar-2: qpvuntsm 6fbf398c (empty) commit
|
||||
@origin: qpvuntsm 6fbf398c (empty) commit
|
||||
foo-1 (deleted)
|
||||
@origin: qpvuntsm 6fbf398c (empty) commit
|
||||
(this branch will be *deleted permanently* on the remote on the
|
||||
|
@ -241,7 +242,7 @@ fn test_branch_delete_export() {
|
|||
test_env.jj_cmd_ok(&repo_path, &["git", "export"]);
|
||||
|
||||
test_env.jj_cmd_ok(&repo_path, &["branch", "delete", "foo"]);
|
||||
let stdout = test_env.jj_cmd_success(&repo_path, &["branch", "list"]);
|
||||
let stdout = test_env.jj_cmd_success(&repo_path, &["branch", "list", "--all"]);
|
||||
insta::assert_snapshot!(stdout, @r###"
|
||||
foo (deleted)
|
||||
@git: rlvkpnrz 65b6b74e (empty) (no description set)
|
||||
|
@ -249,7 +250,7 @@ fn test_branch_delete_export() {
|
|||
"###);
|
||||
|
||||
test_env.jj_cmd_ok(&repo_path, &["git", "export"]);
|
||||
let stdout = test_env.jj_cmd_success(&repo_path, &["branch", "list"]);
|
||||
let stdout = test_env.jj_cmd_success(&repo_path, &["branch", "list", "--all"]);
|
||||
insta::assert_snapshot!(stdout, @r###"
|
||||
"###);
|
||||
}
|
||||
|
@ -262,7 +263,7 @@ fn test_branch_forget_export() {
|
|||
|
||||
test_env.jj_cmd_ok(&repo_path, &["new"]);
|
||||
test_env.jj_cmd_ok(&repo_path, &["branch", "set", "foo"]);
|
||||
let stdout = test_env.jj_cmd_success(&repo_path, &["branch", "list"]);
|
||||
let stdout = test_env.jj_cmd_success(&repo_path, &["branch", "list", "--all"]);
|
||||
insta::assert_snapshot!(stdout, @r###"
|
||||
foo: rlvkpnrz 65b6b74e (empty) (no description set)
|
||||
"###);
|
||||
|
@ -276,7 +277,7 @@ fn test_branch_forget_export() {
|
|||
insta::assert_snapshot!(stderr, @"");
|
||||
// Forgetting a branch deletes local and remote-tracking branches including
|
||||
// the corresponding git-tracking branch.
|
||||
let stdout = test_env.jj_cmd_success(&repo_path, &["branch", "list"]);
|
||||
let stdout = test_env.jj_cmd_success(&repo_path, &["branch", "list", "--all"]);
|
||||
insta::assert_snapshot!(stdout, @"");
|
||||
let stderr = test_env.jj_cmd_failure(&repo_path, &["log", "-r=foo", "--no-graph"]);
|
||||
insta::assert_snapshot!(stderr, @r###"
|
||||
|
@ -290,7 +291,7 @@ fn test_branch_forget_export() {
|
|||
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["git", "export"]);
|
||||
insta::assert_snapshot!(stdout, @"");
|
||||
insta::assert_snapshot!(stderr, @"");
|
||||
let stdout = test_env.jj_cmd_success(&repo_path, &["branch", "list"]);
|
||||
let stdout = test_env.jj_cmd_success(&repo_path, &["branch", "list", "--all"]);
|
||||
insta::assert_snapshot!(stdout, @"");
|
||||
}
|
||||
|
||||
|
@ -334,6 +335,7 @@ fn test_branch_forget_fetched_branch() {
|
|||
test_env.jj_cmd_ok(&repo_path, &["git", "fetch", "--remote=origin"]);
|
||||
insta::assert_snapshot!(get_branch_output(&test_env, &repo_path), @r###"
|
||||
feature1: mzyxwzks 9f01a0e0 message
|
||||
@origin: mzyxwzks 9f01a0e0 message
|
||||
"###);
|
||||
|
||||
// TEST 1: with export-import
|
||||
|
@ -365,6 +367,7 @@ fn test_branch_forget_fetched_branch() {
|
|||
insta::assert_snapshot!(stderr, @"");
|
||||
insta::assert_snapshot!(get_branch_output(&test_env, &repo_path), @r###"
|
||||
feature1: mzyxwzks 9f01a0e0 message
|
||||
@origin: mzyxwzks 9f01a0e0 message
|
||||
"###);
|
||||
|
||||
// TEST 2: No export/import (otherwise the same as test 1)
|
||||
|
@ -376,6 +379,7 @@ fn test_branch_forget_fetched_branch() {
|
|||
insta::assert_snapshot!(stderr, @"");
|
||||
insta::assert_snapshot!(get_branch_output(&test_env, &repo_path), @r###"
|
||||
feature1: mzyxwzks 9f01a0e0 message
|
||||
@origin: mzyxwzks 9f01a0e0 message
|
||||
"###);
|
||||
|
||||
// TEST 3: fetch branch that was moved & forgotten
|
||||
|
@ -401,6 +405,7 @@ fn test_branch_forget_fetched_branch() {
|
|||
insta::assert_snapshot!(stderr, @"");
|
||||
insta::assert_snapshot!(get_branch_output(&test_env, &repo_path), @r###"
|
||||
feature1: ooosovrs 38aefb17 (empty) another message
|
||||
@origin: ooosovrs 38aefb17 (empty) another message
|
||||
"###);
|
||||
}
|
||||
|
||||
|
@ -530,8 +535,10 @@ fn test_branch_track_untrack() {
|
|||
);
|
||||
insta::assert_snapshot!(get_branch_output(&test_env, &repo_path), @r###"
|
||||
feature1: sptzoqmo 7b33f629 commit 1
|
||||
@origin: sptzoqmo 7b33f629 commit 1
|
||||
feature2@origin: sptzoqmo 7b33f629 commit 1
|
||||
main: sptzoqmo 7b33f629 commit 1
|
||||
@origin: sptzoqmo 7b33f629 commit 1
|
||||
"###);
|
||||
|
||||
// Track existing branch. Local branch should result in conflict.
|
||||
|
@ -539,11 +546,13 @@ fn test_branch_track_untrack() {
|
|||
test_env.jj_cmd_ok(&repo_path, &["branch", "track", "feature2@origin"]);
|
||||
insta::assert_snapshot!(get_branch_output(&test_env, &repo_path), @r###"
|
||||
feature1: sptzoqmo 7b33f629 commit 1
|
||||
@origin: sptzoqmo 7b33f629 commit 1
|
||||
feature2 (conflicted):
|
||||
+ qpvuntsm 230dd059 (empty) (no description set)
|
||||
+ sptzoqmo 7b33f629 commit 1
|
||||
@origin (behind by 1 commits): sptzoqmo 7b33f629 commit 1
|
||||
main: sptzoqmo 7b33f629 commit 1
|
||||
@origin: sptzoqmo 7b33f629 commit 1
|
||||
"###);
|
||||
|
||||
// Untrack existing and locally-deleted branches. Branch targets should be
|
||||
|
@ -558,6 +567,7 @@ fn test_branch_track_untrack() {
|
|||
feature1@origin: sptzoqmo 7b33f629 commit 1
|
||||
feature2@origin: sptzoqmo 7b33f629 commit 1
|
||||
main: sptzoqmo 7b33f629 commit 1
|
||||
@origin: sptzoqmo 7b33f629 commit 1
|
||||
"###);
|
||||
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
|
||||
◉ feature1 feature1@origin feature2@origin main 7b33f6295eda
|
||||
|
@ -583,6 +593,7 @@ fn test_branch_track_untrack() {
|
|||
feature1@origin: mmqqkyyt 40dabdaf commit 2
|
||||
feature2@origin: mmqqkyyt 40dabdaf commit 2
|
||||
main: mmqqkyyt 40dabdaf commit 2
|
||||
@origin: mmqqkyyt 40dabdaf commit 2
|
||||
"###);
|
||||
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
|
||||
◉ feature1@origin feature2@origin main 40dabdaf4abe
|
||||
|
@ -615,7 +626,9 @@ fn test_branch_track_untrack() {
|
|||
feature1@origin: wwnpyzpo 3f0f86fa commit 3
|
||||
feature2@origin: wwnpyzpo 3f0f86fa commit 3
|
||||
feature3: wwnpyzpo 3f0f86fa commit 3
|
||||
@origin: wwnpyzpo 3f0f86fa commit 3
|
||||
main: wwnpyzpo 3f0f86fa commit 3
|
||||
@origin: wwnpyzpo 3f0f86fa commit 3
|
||||
"###);
|
||||
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
|
||||
◉ feature1@origin feature2@origin feature3 main 3f0f86fa0e57
|
||||
|
@ -704,6 +717,74 @@ fn test_branch_track_untrack_bad_branches() {
|
|||
"###);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_branch_list() {
|
||||
let test_env = TestEnvironment::default();
|
||||
|
||||
// Initialize remote refs
|
||||
test_env.jj_cmd_ok(test_env.env_root(), &["init", "remote", "--git"]);
|
||||
let remote_path = test_env.env_root().join("remote");
|
||||
for branch in [
|
||||
"remote-sync",
|
||||
"remote-unsync",
|
||||
"remote-untrack",
|
||||
"remote-delete",
|
||||
] {
|
||||
test_env.jj_cmd_ok(&remote_path, &["new", "root()", "-m", branch]);
|
||||
test_env.jj_cmd_ok(&remote_path, &["branch", "set", branch]);
|
||||
}
|
||||
test_env.jj_cmd_ok(&remote_path, &["new"]);
|
||||
test_env.jj_cmd_ok(&remote_path, &["git", "export"]);
|
||||
|
||||
// Initialize local refs
|
||||
let mut remote_git_path = remote_path;
|
||||
remote_git_path.extend([".jj", "repo", "store", "git"]);
|
||||
test_env.jj_cmd_ok(
|
||||
test_env.env_root(),
|
||||
&["git", "clone", remote_git_path.to_str().unwrap(), "local"],
|
||||
);
|
||||
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, &["branch", "set", "local-only"]);
|
||||
|
||||
// Mutate refs in local repository
|
||||
test_env.jj_cmd_ok(&local_path, &["branch", "delete", "remote-delete"]);
|
||||
test_env.jj_cmd_ok(&local_path, &["branch", "delete", "remote-untrack"]);
|
||||
test_env.jj_cmd_ok(&local_path, &["branch", "untrack", "remote-untrack@origin"]);
|
||||
test_env.jj_cmd_ok(
|
||||
&local_path,
|
||||
&["branch", "set", "--allow-backwards", "remote-unsync"],
|
||||
);
|
||||
|
||||
// Synchronized tracking remotes aren't listed by default
|
||||
insta::assert_snapshot!(
|
||||
test_env.jj_cmd_success(&local_path, &["branch", "list"]), @r###"
|
||||
local-only: wqnwkozp 4e887f78 (empty) local-only
|
||||
remote-delete (deleted)
|
||||
@origin: mnmymoky 203e60eb (empty) remote-delete
|
||||
(this branch will be *deleted permanently* on the remote on the
|
||||
next `jj git push`. Use `jj branch forget` to prevent this)
|
||||
remote-sync: zwtyzrop c761c7ea (empty) remote-sync
|
||||
remote-unsync: wqnwkozp 4e887f78 (empty) local-only
|
||||
@origin (ahead by 1 commits, behind by 1 commits): qpsqxpyq 38ef8af7 (empty) remote-unsync
|
||||
remote-untrack@origin: vmortlor 71a16b05 (empty) remote-untrack
|
||||
"###);
|
||||
|
||||
insta::assert_snapshot!(
|
||||
test_env.jj_cmd_success(&local_path, &["branch", "list", "--all"]), @r###"
|
||||
local-only: wqnwkozp 4e887f78 (empty) local-only
|
||||
remote-delete (deleted)
|
||||
@origin: mnmymoky 203e60eb (empty) remote-delete
|
||||
(this branch will be *deleted permanently* on the remote on the
|
||||
next `jj git push`. Use `jj branch forget` to prevent this)
|
||||
remote-sync: zwtyzrop c761c7ea (empty) remote-sync
|
||||
@origin: zwtyzrop c761c7ea (empty) remote-sync
|
||||
remote-unsync: wqnwkozp 4e887f78 (empty) local-only
|
||||
@origin (ahead by 1 commits, behind by 1 commits): qpsqxpyq 38ef8af7 (empty) remote-unsync
|
||||
remote-untrack@origin: vmortlor 71a16b05 (empty) remote-untrack
|
||||
"###);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_branch_list_filtered_by_revset() {
|
||||
let test_env = TestEnvironment::default();
|
||||
|
@ -808,5 +889,5 @@ fn get_log_output(test_env: &TestEnvironment, cwd: &Path) -> String {
|
|||
}
|
||||
|
||||
fn get_branch_output(test_env: &TestEnvironment, repo_path: &Path) -> String {
|
||||
test_env.jj_cmd_success(repo_path, &["branch", "list"])
|
||||
test_env.jj_cmd_success(repo_path, &["branch", "list", "--all"])
|
||||
}
|
||||
|
|
|
@ -230,9 +230,14 @@ fn test_git_clone_colocate() {
|
|||
"###);
|
||||
|
||||
// The old default branch "master" shouldn't exist.
|
||||
let stdout = test_env.jj_cmd_success(&test_env.env_root().join("clone"), &["branch", "list"]);
|
||||
let stdout = test_env.jj_cmd_success(
|
||||
&test_env.env_root().join("clone"),
|
||||
&["branch", "list", "--all"],
|
||||
);
|
||||
insta::assert_snapshot!(stdout, @r###"
|
||||
main: mzyxwzks 9f01a0e0 message
|
||||
@git: mzyxwzks 9f01a0e0 message
|
||||
@origin: mzyxwzks 9f01a0e0 message
|
||||
"###);
|
||||
|
||||
// Subsequent fetch should just work even if the source path was relative
|
||||
|
|
|
@ -377,9 +377,10 @@ fn test_git_colocated_branch_forget() {
|
|||
◉ 230dd059e1b059aefc0da06a2e5a7dbf22362f22 HEAD@git
|
||||
◉ 0000000000000000000000000000000000000000
|
||||
"###);
|
||||
let stdout = test_env.jj_cmd_success(&workspace_root, &["branch", "list"]);
|
||||
let stdout = test_env.jj_cmd_success(&workspace_root, &["branch", "list", "--all"]);
|
||||
insta::assert_snapshot!(stdout, @r###"
|
||||
foo: rlvkpnrz 65b6b74e (empty) (no description set)
|
||||
@git: rlvkpnrz 65b6b74e (empty) (no description set)
|
||||
"###);
|
||||
|
||||
let (stdout, stderr) = test_env.jj_cmd_ok(&workspace_root, &["branch", "forget", "foo"]);
|
||||
|
@ -387,7 +388,7 @@ fn test_git_colocated_branch_forget() {
|
|||
insta::assert_snapshot!(stderr, @"");
|
||||
// A forgotten branch is deleted in the git repo. For a detailed demo explaining
|
||||
// this, see `test_branch_forget_export` in `test_branch_command.rs`.
|
||||
let stdout = test_env.jj_cmd_success(&workspace_root, &["branch", "list"]);
|
||||
let stdout = test_env.jj_cmd_success(&workspace_root, &["branch", "list", "--all"]);
|
||||
insta::assert_snapshot!(stdout, @"");
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ fn add_git_remote(test_env: &TestEnvironment, repo_path: &Path, remote: &str) {
|
|||
}
|
||||
|
||||
fn get_branch_output(test_env: &TestEnvironment, repo_path: &Path) -> String {
|
||||
test_env.jj_cmd_success(repo_path, &["branch", "list"])
|
||||
test_env.jj_cmd_success(repo_path, &["branch", "list", "--all"])
|
||||
}
|
||||
|
||||
fn create_commit(test_env: &TestEnvironment, repo_path: &Path, name: &str, parents: &[&str]) {
|
||||
|
@ -83,6 +83,7 @@ fn test_git_fetch_default_remote() {
|
|||
test_env.jj_cmd_ok(&repo_path, &["git", "fetch"]);
|
||||
insta::assert_snapshot!(get_branch_output(&test_env, &repo_path), @r###"
|
||||
origin: oputwtnw ffecd2d6 message
|
||||
@origin: oputwtnw ffecd2d6 message
|
||||
"###);
|
||||
}
|
||||
|
||||
|
@ -100,6 +101,7 @@ fn test_git_fetch_single_remote() {
|
|||
.stderr("Fetching from the only existing remote: rem1\n");
|
||||
insta::assert_snapshot!(get_branch_output(&test_env, &repo_path), @r###"
|
||||
rem1: qxosxrvv 6a211027 message
|
||||
@rem1: qxosxrvv 6a211027 message
|
||||
"###);
|
||||
}
|
||||
|
||||
|
@ -116,6 +118,7 @@ fn test_git_fetch_single_remote_all_remotes_flag() {
|
|||
.success();
|
||||
insta::assert_snapshot!(get_branch_output(&test_env, &repo_path), @r###"
|
||||
rem1: qxosxrvv 6a211027 message
|
||||
@rem1: qxosxrvv 6a211027 message
|
||||
"###);
|
||||
}
|
||||
|
||||
|
@ -129,6 +132,7 @@ fn test_git_fetch_single_remote_from_arg() {
|
|||
test_env.jj_cmd_ok(&repo_path, &["git", "fetch", "--remote", "rem1"]);
|
||||
insta::assert_snapshot!(get_branch_output(&test_env, &repo_path), @r###"
|
||||
rem1: qxosxrvv 6a211027 message
|
||||
@rem1: qxosxrvv 6a211027 message
|
||||
"###);
|
||||
}
|
||||
|
||||
|
@ -143,6 +147,7 @@ fn test_git_fetch_single_remote_from_config() {
|
|||
test_env.jj_cmd_ok(&repo_path, &["git", "fetch"]);
|
||||
insta::assert_snapshot!(get_branch_output(&test_env, &repo_path), @r###"
|
||||
rem1: qxosxrvv 6a211027 message
|
||||
@rem1: qxosxrvv 6a211027 message
|
||||
"###);
|
||||
}
|
||||
|
||||
|
@ -160,7 +165,9 @@ fn test_git_fetch_multiple_remotes() {
|
|||
);
|
||||
insta::assert_snapshot!(get_branch_output(&test_env, &repo_path), @r###"
|
||||
rem1: qxosxrvv 6a211027 message
|
||||
@rem1: qxosxrvv 6a211027 message
|
||||
rem2: yszkquru 2497a8a0 message
|
||||
@rem2: yszkquru 2497a8a0 message
|
||||
"###);
|
||||
}
|
||||
|
||||
|
@ -175,7 +182,9 @@ fn test_git_fetch_all_remotes() {
|
|||
test_env.jj_cmd_ok(&repo_path, &["git", "fetch", "--all-remotes"]);
|
||||
insta::assert_snapshot!(get_branch_output(&test_env, &repo_path), @r###"
|
||||
rem1: qxosxrvv 6a211027 message
|
||||
@rem1: qxosxrvv 6a211027 message
|
||||
rem2: yszkquru 2497a8a0 message
|
||||
@rem2: yszkquru 2497a8a0 message
|
||||
"###);
|
||||
}
|
||||
|
||||
|
@ -191,7 +200,9 @@ fn test_git_fetch_multiple_remotes_from_config() {
|
|||
test_env.jj_cmd_ok(&repo_path, &["git", "fetch"]);
|
||||
insta::assert_snapshot!(get_branch_output(&test_env, &repo_path), @r###"
|
||||
rem1: qxosxrvv 6a211027 message
|
||||
@rem1: qxosxrvv 6a211027 message
|
||||
rem2: yszkquru 2497a8a0 message
|
||||
@rem2: yszkquru 2497a8a0 message
|
||||
"###);
|
||||
}
|
||||
|
||||
|
@ -248,7 +259,7 @@ fn test_git_fetch_from_remote_named_git() {
|
|||
"###);
|
||||
|
||||
// Implicit import shouldn't fail because of the remote ref.
|
||||
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["branch", "list"]);
|
||||
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["branch", "list", "--all"]);
|
||||
insta::assert_snapshot!(stdout, @"");
|
||||
insta::assert_snapshot!(stderr, @"");
|
||||
|
||||
|
@ -261,9 +272,11 @@ fn test_git_fetch_from_remote_named_git() {
|
|||
|
||||
// The remote can be renamed, and the ref can be imported.
|
||||
test_env.jj_cmd_ok(&repo_path, &["git", "remote", "rename", "git", "bar"]);
|
||||
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["branch", "list"]);
|
||||
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["branch", "list", "--all"]);
|
||||
insta::assert_snapshot!(stdout, @r###"
|
||||
git: mrylzrtu 76fc7466 message
|
||||
@bar: mrylzrtu 76fc7466 message
|
||||
@git: mrylzrtu 76fc7466 message
|
||||
"###);
|
||||
insta::assert_snapshot!(stderr, @r###"
|
||||
Done importing changes from the underlying Git repo.
|
||||
|
@ -279,6 +292,7 @@ fn test_git_fetch_prune_before_updating_tips() {
|
|||
test_env.jj_cmd_ok(&repo_path, &["git", "fetch"]);
|
||||
insta::assert_snapshot!(get_branch_output(&test_env, &repo_path), @r###"
|
||||
origin: oputwtnw ffecd2d6 message
|
||||
@origin: oputwtnw ffecd2d6 message
|
||||
"###);
|
||||
|
||||
// Remove origin branch in git repo and create origin/subname
|
||||
|
@ -292,6 +306,7 @@ fn test_git_fetch_prune_before_updating_tips() {
|
|||
test_env.jj_cmd_ok(&repo_path, &["git", "fetch"]);
|
||||
insta::assert_snapshot!(get_branch_output(&test_env, &repo_path), @r###"
|
||||
origin/subname: oputwtnw ffecd2d6 message
|
||||
@origin: oputwtnw ffecd2d6 message
|
||||
"###);
|
||||
}
|
||||
|
||||
|
@ -337,6 +352,7 @@ fn test_git_fetch_conflicting_branches_colocated() {
|
|||
test_env.jj_cmd_ok(&repo_path, &["branch", "create", "rem1"]);
|
||||
insta::assert_snapshot!(get_branch_output(&test_env, &repo_path), @r###"
|
||||
rem1: zsuskuln f652c321 (empty) (no description set)
|
||||
@git: zsuskuln f652c321 (empty) (no description set)
|
||||
"###);
|
||||
|
||||
test_env.jj_cmd_ok(
|
||||
|
@ -424,9 +440,13 @@ fn test_git_fetch_all() {
|
|||
insta::assert_snapshot!(stderr, @"");
|
||||
insta::assert_snapshot!(get_branch_output(&test_env, &target_jj_repo_path), @r###"
|
||||
a1: nknoxmzm 359a9a02 descr_for_a1
|
||||
@origin: nknoxmzm 359a9a02 descr_for_a1
|
||||
a2: qkvnknrk decaa396 descr_for_a2
|
||||
@origin: qkvnknrk decaa396 descr_for_a2
|
||||
b: vpupmnsl c7d4bdcb descr_for_b
|
||||
@origin: vpupmnsl c7d4bdcb descr_for_b
|
||||
trunk1: zowqyktl ff36dc55 descr_for_trunk1
|
||||
@origin: zowqyktl ff36dc55 descr_for_trunk1
|
||||
"###);
|
||||
insta::assert_snapshot!(get_log_output(&test_env, &target_jj_repo_path), @r###"
|
||||
◉ c7d4bdcbc215 descr_for_b b
|
||||
|
@ -474,10 +494,13 @@ fn test_git_fetch_all() {
|
|||
"###);
|
||||
insta::assert_snapshot!(get_branch_output(&test_env, &target_jj_repo_path), @r###"
|
||||
a1: nknoxmzm 359a9a02 descr_for_a1
|
||||
@origin: nknoxmzm 359a9a02 descr_for_a1
|
||||
a2: qkvnknrk decaa396 descr_for_a2
|
||||
@origin: qkvnknrk decaa396 descr_for_a2
|
||||
b: vpupmnsl 061eddbb new_descr_for_b_to_create_conflict
|
||||
@origin (ahead by 1 commits, behind by 1 commits): vpupmnsl c7d4bdcb descr_for_b
|
||||
trunk1: zowqyktl ff36dc55 descr_for_trunk1
|
||||
@origin: zowqyktl ff36dc55 descr_for_trunk1
|
||||
"###);
|
||||
let (stdout, stderr) = test_env.jj_cmd_ok(&target_jj_repo_path, &["git", "fetch"]);
|
||||
insta::assert_snapshot!(stdout, @"");
|
||||
|
@ -486,14 +509,18 @@ fn test_git_fetch_all() {
|
|||
"###);
|
||||
insta::assert_snapshot!(get_branch_output(&test_env, &target_jj_repo_path), @r###"
|
||||
a1: quxllqov 0424f6df descr_for_a1
|
||||
@origin: quxllqov 0424f6df descr_for_a1
|
||||
a2: osusxwst 91e46b4b descr_for_a2
|
||||
@origin: osusxwst 91e46b4b descr_for_a2
|
||||
b (conflicted):
|
||||
- vpupmnsl c7d4bdcb descr_for_b
|
||||
+ vpupmnsl 061eddbb new_descr_for_b_to_create_conflict
|
||||
+ vktnwlsu babc4922 descr_for_b
|
||||
@origin (behind by 1 commits): vktnwlsu babc4922 descr_for_b
|
||||
trunk1: zowqyktl ff36dc55 descr_for_trunk1
|
||||
@origin: zowqyktl ff36dc55 descr_for_trunk1
|
||||
trunk2: umznmzko 8f1f14fb descr_for_trunk2
|
||||
@origin: umznmzko 8f1f14fb descr_for_trunk2
|
||||
"###);
|
||||
insta::assert_snapshot!(get_log_output(&test_env, &target_jj_repo_path), @r###"
|
||||
◉ babc49226c14 descr_for_b b?? b@origin
|
||||
|
@ -568,6 +595,7 @@ fn test_git_fetch_some_of_many_branches() {
|
|||
// ...check what the intermediate state looks like...
|
||||
insta::assert_snapshot!(get_branch_output(&test_env, &target_jj_repo_path), @r###"
|
||||
b: vpupmnsl c7d4bdcb descr_for_b
|
||||
@origin: vpupmnsl c7d4bdcb descr_for_b
|
||||
"###);
|
||||
// ...then fetch two others with a glob.
|
||||
let (stdout, stderr) =
|
||||
|
@ -662,7 +690,9 @@ fn test_git_fetch_some_of_many_branches() {
|
|||
// We left a2 where it was before, let's see how `jj branch list` sees this.
|
||||
insta::assert_snapshot!(get_branch_output(&test_env, &target_jj_repo_path), @r###"
|
||||
a1: kmuktwqx 6f4e1c4d descr_for_a1
|
||||
@origin: kmuktwqx 6f4e1c4d descr_for_a1
|
||||
a2: qkvnknrk decaa396 descr_for_a2
|
||||
@origin: qkvnknrk decaa396 descr_for_a2
|
||||
b (conflicted):
|
||||
- vpupmnsl c7d4bdcb descr_for_b
|
||||
+ vpupmnsl 2be688d8 new_descr_for_b_to_create_conflict
|
||||
|
@ -695,7 +725,9 @@ fn test_git_fetch_some_of_many_branches() {
|
|||
"###);
|
||||
insta::assert_snapshot!(get_branch_output(&test_env, &target_jj_repo_path), @r###"
|
||||
a1: kmuktwqx 6f4e1c4d descr_for_a1
|
||||
@origin: kmuktwqx 6f4e1c4d descr_for_a1
|
||||
a2: xwxurvnt 010977d6 descr_for_a2
|
||||
@origin: xwxurvnt 010977d6 descr_for_a2
|
||||
b (conflicted):
|
||||
- vpupmnsl c7d4bdcb descr_for_b
|
||||
+ vpupmnsl 2be688d8 new_descr_for_b_to_create_conflict
|
||||
|
@ -822,6 +854,7 @@ fn test_fetch_undo_what() {
|
|||
"###);
|
||||
insta::assert_snapshot!(get_branch_output(&test_env, &repo_path), @r###"
|
||||
b: vpupmnsl c7d4bdcb descr_for_b
|
||||
@origin: vpupmnsl c7d4bdcb descr_for_b
|
||||
"###);
|
||||
|
||||
// We can undo the change in the repo without moving the remote-tracking branch
|
||||
|
@ -1143,6 +1176,7 @@ fn test_git_fetch_remote_only_branch() {
|
|||
test_env.jj_cmd_ok(&repo_path, &["git", "fetch", "--remote=origin"]);
|
||||
insta::assert_snapshot!(get_branch_output(&test_env, &repo_path), @r###"
|
||||
feature1: mzyxwzks 9f01a0e0 message
|
||||
@origin: mzyxwzks 9f01a0e0 message
|
||||
"###);
|
||||
|
||||
git_repo
|
||||
|
@ -1167,6 +1201,7 @@ fn test_git_fetch_remote_only_branch() {
|
|||
"###);
|
||||
insta::assert_snapshot!(get_branch_output(&test_env, &repo_path), @r###"
|
||||
feature1: mzyxwzks 9f01a0e0 message
|
||||
@origin: mzyxwzks 9f01a0e0 message
|
||||
feature2@origin: mzyxwzks 9f01a0e0 message
|
||||
"###);
|
||||
}
|
||||
|
|
|
@ -152,6 +152,7 @@ fn test_git_import_undo() {
|
|||
insta::assert_snapshot!(stderr, @"");
|
||||
insta::assert_snapshot!(get_branch_output(&test_env, &repo_path), @r###"
|
||||
a: qpvuntsm 230dd059 (empty) (no description set)
|
||||
@git: qpvuntsm 230dd059 (empty) (no description set)
|
||||
"###);
|
||||
|
||||
// "git import" can be undone by default.
|
||||
|
@ -165,6 +166,7 @@ fn test_git_import_undo() {
|
|||
insta::assert_snapshot!(stderr, @"");
|
||||
insta::assert_snapshot!(get_branch_output(&test_env, &repo_path), @r###"
|
||||
a: qpvuntsm 230dd059 (empty) (no description set)
|
||||
@git: qpvuntsm 230dd059 (empty) (no description set)
|
||||
"###);
|
||||
}
|
||||
|
||||
|
@ -193,6 +195,7 @@ fn test_git_import_move_export_with_default_undo() {
|
|||
insta::assert_snapshot!(stderr, @"");
|
||||
insta::assert_snapshot!(get_branch_output(&test_env, &repo_path), @r###"
|
||||
a: qpvuntsm 230dd059 (empty) (no description set)
|
||||
@git: qpvuntsm 230dd059 (empty) (no description set)
|
||||
"###);
|
||||
|
||||
// Move branch "a" and export to git repo
|
||||
|
@ -207,6 +210,7 @@ fn test_git_import_move_export_with_default_undo() {
|
|||
insta::assert_snapshot!(stderr, @"");
|
||||
insta::assert_snapshot!(get_branch_output(&test_env, &repo_path), @r###"
|
||||
a: yqosqzyt 096dc80d (empty) (no description set)
|
||||
@git: yqosqzyt 096dc80d (empty) (no description set)
|
||||
"###);
|
||||
|
||||
// "git import" can be undone with the default `restore` behavior, as shown in
|
||||
|
@ -237,11 +241,12 @@ fn test_git_import_move_export_with_default_undo() {
|
|||
insta::assert_snapshot!(stderr, @"");
|
||||
insta::assert_snapshot!(get_branch_output(&test_env, &repo_path), @r###"
|
||||
a: yqosqzyt 096dc80d (empty) (no description set)
|
||||
@git: yqosqzyt 096dc80d (empty) (no description set)
|
||||
"###);
|
||||
}
|
||||
|
||||
fn get_branch_output(test_env: &TestEnvironment, repo_path: &Path) -> String {
|
||||
test_env.jj_cmd_success(repo_path, &["branch", "list"])
|
||||
test_env.jj_cmd_success(repo_path, &["branch", "list", "--all"])
|
||||
}
|
||||
|
||||
fn get_git_repo_refs(git_repo: &git2::Repository) -> Vec<(String, CommitId)> {
|
||||
|
|
|
@ -73,7 +73,7 @@ fn test_git_push_current_branch() {
|
|||
test_env.jj_cmd_ok(&workspace_root, &["branch", "create", "my-branch"]);
|
||||
test_env.jj_cmd_ok(&workspace_root, &["describe", "-m", "foo"]);
|
||||
// Check the setup
|
||||
let stdout = test_env.jj_cmd_success(&workspace_root, &["branch", "list"]);
|
||||
let stdout = test_env.jj_cmd_success(&workspace_root, &["branch", "list", "--all"]);
|
||||
insta::assert_snapshot!(stdout, @r###"
|
||||
branch1: lzmmnrxq 19e00bf6 (empty) modified branch1 commit
|
||||
@origin (ahead by 1 commits, behind by 1 commits): lzmmnrxq 45a3aa29 (empty) description 1
|
||||
|
@ -97,12 +97,14 @@ fn test_git_push_current_branch() {
|
|||
Move branch branch2 from 8476341eb395 to 10ee3363b259
|
||||
Add branch my-branch to 10ee3363b259
|
||||
"###);
|
||||
let stdout = test_env.jj_cmd_success(&workspace_root, &["branch", "list"]);
|
||||
let stdout = test_env.jj_cmd_success(&workspace_root, &["branch", "list", "--all"]);
|
||||
insta::assert_snapshot!(stdout, @r###"
|
||||
branch1: lzmmnrxq 19e00bf6 (empty) modified branch1 commit
|
||||
@origin (ahead by 1 commits, behind by 1 commits): lzmmnrxq 45a3aa29 (empty) description 1
|
||||
branch2: yostqsxw 10ee3363 (empty) foo
|
||||
@origin: yostqsxw 10ee3363 (empty) foo
|
||||
my-branch: yostqsxw 10ee3363 (empty) foo
|
||||
@origin: yostqsxw 10ee3363 (empty) foo
|
||||
"###);
|
||||
}
|
||||
|
||||
|
@ -247,10 +249,12 @@ fn test_git_push_locally_created_and_rewritten() {
|
|||
// Rewrite it and push again, which would fail if the pushed branch weren't
|
||||
// set to "tracking"
|
||||
test_env.jj_cmd_ok(&workspace_root, &["describe", "-mlocal 2"]);
|
||||
let stdout = test_env.jj_cmd_success(&workspace_root, &["branch", "list"]);
|
||||
let stdout = test_env.jj_cmd_success(&workspace_root, &["branch", "list", "--all"]);
|
||||
insta::assert_snapshot!(stdout, @r###"
|
||||
branch1: lzmmnrxq 45a3aa29 (empty) description 1
|
||||
@origin: lzmmnrxq 45a3aa29 (empty) description 1
|
||||
branch2: rlzusymt 8476341e (empty) description 2
|
||||
@origin: rlzusymt 8476341e (empty) description 2
|
||||
my: vruxwmqv bde1d2e4 (empty) local 2
|
||||
@origin (ahead by 1 commits, behind by 1 commits): vruxwmqv fcc99992 (empty) local 1
|
||||
"###);
|
||||
|
@ -272,7 +276,7 @@ fn test_git_push_multiple() {
|
|||
test_env.jj_cmd_ok(&workspace_root, &["branch", "create", "my-branch"]);
|
||||
test_env.jj_cmd_ok(&workspace_root, &["describe", "-m", "foo"]);
|
||||
// Check the setup
|
||||
let stdout = test_env.jj_cmd_success(&workspace_root, &["branch", "list"]);
|
||||
let stdout = test_env.jj_cmd_success(&workspace_root, &["branch", "list", "--all"]);
|
||||
insta::assert_snapshot!(stdout, @r###"
|
||||
branch1 (deleted)
|
||||
@origin: lzmmnrxq 45a3aa29 (empty) description 1
|
||||
|
@ -333,10 +337,12 @@ fn test_git_push_multiple() {
|
|||
Force branch branch2 from 8476341eb395 to 15dcdaa4f12f
|
||||
Add branch my-branch to 15dcdaa4f12f
|
||||
"###);
|
||||
let stdout = test_env.jj_cmd_success(&workspace_root, &["branch", "list"]);
|
||||
let stdout = test_env.jj_cmd_success(&workspace_root, &["branch", "list", "--all"]);
|
||||
insta::assert_snapshot!(stdout, @r###"
|
||||
branch2: yqosqzyt 15dcdaa4 (empty) foo
|
||||
@origin: yqosqzyt 15dcdaa4 (empty) foo
|
||||
my-branch: yqosqzyt 15dcdaa4 (empty) foo
|
||||
@origin: yqosqzyt 15dcdaa4 (empty) foo
|
||||
"###);
|
||||
let stdout = test_env.jj_cmd_success(&workspace_root, &["log", "-rall()"]);
|
||||
insta::assert_snapshot!(stdout, @r###"
|
||||
|
@ -666,8 +672,10 @@ fn test_git_push_conflicting_branches() {
|
|||
test_env.jj_cmd_ok(&workspace_root, &["new", "root()", "-m=description 3"]);
|
||||
test_env.jj_cmd_ok(&workspace_root, &["branch", "set", "branch2"]);
|
||||
test_env.jj_cmd_ok(&workspace_root, &["git", "fetch"]);
|
||||
insta::assert_snapshot!(test_env.jj_cmd_success(&workspace_root, &["branch", "list"]), @r###"
|
||||
insta::assert_snapshot!(
|
||||
test_env.jj_cmd_success(&workspace_root, &["branch", "list", "--all"]), @r###"
|
||||
branch1: lzmmnrxq 45a3aa29 (empty) description 1
|
||||
@origin: lzmmnrxq 45a3aa29 (empty) description 1
|
||||
branch2 (conflicted):
|
||||
+ yostqsxw 8e670e2d (empty) description 3
|
||||
+ rlzusymt 8476341e (empty) description 2
|
||||
|
|
|
@ -84,6 +84,7 @@ fn test_git_push_undo() {
|
|||
// remote-tracking | BB | BB | BB
|
||||
insta::assert_snapshot!(get_branch_output(&test_env, &repo_path), @r###"
|
||||
main: qpvuntsm 8c05de15 (empty) BB
|
||||
@origin: qpvuntsm 8c05de15 (empty) BB
|
||||
"###);
|
||||
|
||||
// Undo the push
|
||||
|
@ -156,6 +157,7 @@ fn test_git_push_undo_with_import() {
|
|||
// remote-tracking | BB | BB | BB
|
||||
insta::assert_snapshot!(get_branch_output(&test_env, &repo_path), @r###"
|
||||
main: qpvuntsm 8c05de15 (empty) BB
|
||||
@origin: qpvuntsm 8c05de15 (empty) BB
|
||||
"###);
|
||||
|
||||
// Undo the push
|
||||
|
@ -183,6 +185,7 @@ fn test_git_push_undo_with_import() {
|
|||
// remote-tracking | BB | BB | BB
|
||||
insta::assert_snapshot!(get_branch_output(&test_env, &repo_path), @r###"
|
||||
main: qpvuntsm 8c05de15 (empty) BB
|
||||
@origin: qpvuntsm 8c05de15 (empty) BB
|
||||
"###);
|
||||
test_env.advance_test_rng_seed_to_multiple_of(100_000);
|
||||
test_env.jj_cmd_ok(&repo_path, &["describe", "-m", "CC"]);
|
||||
|
@ -222,6 +225,7 @@ fn test_git_push_undo_colocated() {
|
|||
// remote-tracking | AA | AA | AA
|
||||
insta::assert_snapshot!(get_branch_output(&test_env, &repo_path), @r###"
|
||||
main: qpvuntsm 8c05de15 (empty) BB
|
||||
@git: qpvuntsm 8c05de15 (empty) BB
|
||||
@origin (ahead by 1 commits, behind by 1 commits): qpvuntsm 0cffb614 (empty) AA
|
||||
"###);
|
||||
let pre_push_opid = test_env.current_operation_id(&repo_path);
|
||||
|
@ -234,6 +238,8 @@ fn test_git_push_undo_colocated() {
|
|||
// remote-tracking | BB | BB | BB
|
||||
insta::assert_snapshot!(get_branch_output(&test_env, &repo_path), @r###"
|
||||
main: qpvuntsm 8c05de15 (empty) BB
|
||||
@git: qpvuntsm 8c05de15 (empty) BB
|
||||
@origin: qpvuntsm 8c05de15 (empty) BB
|
||||
"###);
|
||||
|
||||
// Undo the push
|
||||
|
@ -254,6 +260,7 @@ fn test_git_push_undo_colocated() {
|
|||
// remote-tracking | AA | AA | AA
|
||||
insta::assert_snapshot!(get_branch_output(&test_env, &repo_path), @r###"
|
||||
main: qpvuntsm 8c05de15 (empty) BB
|
||||
@git: qpvuntsm 8c05de15 (empty) BB
|
||||
@origin (ahead by 1 commits, behind by 1 commits): qpvuntsm 0cffb614 (empty) AA
|
||||
"###);
|
||||
test_env.advance_test_rng_seed_to_multiple_of(100_000);
|
||||
|
@ -289,6 +296,7 @@ fn test_git_push_undo_repo_only() {
|
|||
test_env.jj_cmd_ok(&repo_path, &["git", "push"]);
|
||||
insta::assert_snapshot!(get_branch_output(&test_env, &repo_path), @r###"
|
||||
main: qpvuntsm 0cffb614 (empty) AA
|
||||
@origin: qpvuntsm 0cffb614 (empty) AA
|
||||
"###);
|
||||
test_env.advance_test_rng_seed_to_multiple_of(100_000);
|
||||
test_env.jj_cmd_ok(&repo_path, &["describe", "-m", "BB"]);
|
||||
|
@ -306,6 +314,7 @@ fn test_git_push_undo_repo_only() {
|
|||
);
|
||||
insta::assert_snapshot!(get_branch_output(&test_env, &repo_path), @r###"
|
||||
main: qpvuntsm 8c05de15 (empty) BB
|
||||
@origin: qpvuntsm 8c05de15 (empty) BB
|
||||
"###);
|
||||
test_env.advance_test_rng_seed_to_multiple_of(100_000);
|
||||
test_env.jj_cmd_ok(&repo_path, &["describe", "-m", "CC"]);
|
||||
|
@ -318,5 +327,5 @@ fn test_git_push_undo_repo_only() {
|
|||
}
|
||||
|
||||
fn get_branch_output(test_env: &TestEnvironment, repo_path: &Path) -> String {
|
||||
test_env.jj_cmd_success(repo_path, &["branch", "list"])
|
||||
test_env.jj_cmd_success(repo_path, &["branch", "list", "--all"])
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue