-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
branch forget: force
jj git export
of relevant branches
This is a bit unwieldy; see a comment in the code for a detailed explanation. We'll have to decide whether we prefer this, or we prefer the approach of jj-vcs#1771, or we have a better idea.
- Loading branch information
Showing
2 changed files
with
62 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -236,46 +236,24 @@ fn test_branch_forget_export() { | |
// Exporting the branch to git creates a local-git tracking branch | ||
let stdout = test_env.jj_cmd_success(&repo_path, &["git", "export"]); | ||
insta::assert_snapshot!(stdout, @""); | ||
let stdout = test_env.jj_cmd_success(&repo_path, &["log", "-r=foo@git", "--no-graph"]); | ||
insta::assert_snapshot!(stdout, @r###" | ||
rlvkpnrzqnoo [email protected] 2001-02-03 04:05:08.000 +07:00 foo 65b6b74e0897 | ||
(empty) (no description set) | ||
"###); | ||
let stdout = test_env.jj_cmd_success(&repo_path, &["branch", "forget", "foo"]); | ||
insta::assert_snapshot!(stdout, @""); | ||
// Forgetting a branch does not delete its local-git tracking branch. This is | ||
// the opposite of what happens to remote-tracking branches. | ||
// TODO: Consider allowing forgetting local-git tracking branches as an option | ||
// Forgetting a branch deletes its local-git tracking branch immediately | ||
let stdout = test_env.jj_cmd_success(&repo_path, &["branch", "list"]); | ||
insta::assert_snapshot!(stdout, @r###" | ||
foo (forgotten) | ||
@git: 65b6b74e0897 (no description set) | ||
(this branch will be deleted from the underlying Git repo on the next `jj git export`) | ||
insta::assert_snapshot!(stdout, @""); | ||
let stderr = test_env.jj_cmd_failure(&repo_path, &["log", "-r=foo@git", "--no-graph"]); | ||
insta::assert_snapshot!(stderr, @r###" | ||
Error: Revision "foo@git" doesn't exist | ||
"###); | ||
let stderr = test_env.jj_cmd_failure(&repo_path, &["log", "-r=foo", "--no-graph"]); | ||
insta::assert_snapshot!(stderr, @r###" | ||
Error: Revision "foo" doesn't exist | ||
"###); | ||
let stdout = test_env.jj_cmd_success(&repo_path, &["log", "-r=foo@git", "--no-graph"]); | ||
insta::assert_snapshot!(stdout, @r###" | ||
rlvkpnrzqnoo [email protected] 2001-02-03 04:05:08.000 +07:00 65b6b74e0897 | ||
(empty) (no description set) | ||
"###); | ||
|
||
// The presence of the @git branch means that a `jj git import` is a no-op... | ||
let stdout = test_env.jj_cmd_success(&repo_path, &["git", "import"]); | ||
insta::assert_snapshot!(stdout, @r###" | ||
Nothing changed. | ||
"###); | ||
// ... and a `jj git export` will delete the branch from git and will delete the | ||
// git-tracking branch. In a colocated repo, this will happen automatically | ||
// immediately after a `jj branch forget`. This is demonstrated in | ||
// `test_git_colocated_branch_forget` in test_git_colocated.rs | ||
let stdout = test_env.jj_cmd_success(&repo_path, &["git", "export"]); | ||
insta::assert_snapshot!(stdout, @""); | ||
let stdout = test_env.jj_cmd_success(&repo_path, &["branch", "list"]); | ||
insta::assert_snapshot!(stdout, @""); | ||
|
||
// Note that if `jj branch forget` *did* delete foo@git, a subsequent `jj | ||
// git export` would be a no-op and a `jj git import` would resurrect | ||
// the branch. In a normal repo, that might be OK. In a colocated repo, | ||
// this would automatically happen before the next command, making `jj | ||
// branch forget` useless. | ||
} | ||
|
||
#[test] | ||
|
@@ -331,17 +309,9 @@ fn test_branch_forget_fetched_branch() { | |
// Technically, this is because `jj branch forget` preserved | ||
// the ref in jj view's `git_refs` tracking the local git repo's remote-tracking | ||
// branch. | ||
insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["git", "export"]), @""); | ||
insta::assert_snapshot!(test_env.jj_cmd_success(&repo_path, &["git", "import"]), @r###" | ||
Nothing changed. | ||
"###); | ||
insta::assert_snapshot!(get_branch_output(&test_env, &repo_path), @""); | ||
|
||
// We can fetch feature1 again. | ||
// BUG/Short-term TODO: it looks like the bug is fixed, but actually this only | ||
// works because we did `jj git export` above and that deleted the | ||
// remote-tracking branch in the git repo. Note that the BUG below is NOT | ||
// fixed. | ||
let stdout = test_env.jj_cmd_success(&repo_path, &["git", "fetch", "--remote=origin"]); | ||
insta::assert_snapshot!(stdout, @""); | ||
insta::assert_snapshot!(get_branch_output(&test_env, &repo_path), @r###" | ||
|
@@ -362,13 +332,11 @@ fn test_branch_forget_fetched_branch() { | |
let stdout = test_env.jj_cmd_success(&repo_path, &["branch", "forget", "feature1"]); | ||
insta::assert_snapshot!(stdout, @""); | ||
|
||
// BUG: fetching a moved branch creates a move-deletion conflict | ||
// Fetching a moved branch does not create a conflict | ||
let stdout = test_env.jj_cmd_success(&repo_path, &["git", "fetch", "--remote=origin"]); | ||
insta::assert_snapshot!(stdout, @""); | ||
insta::assert_snapshot!(get_branch_output(&test_env, &repo_path), @r###" | ||
feature1 (conflicted): | ||
- 9f01a0e04879 message | ||
+ 38aefb173976 another message | ||
feature1: 38aefb173976 another message | ||
"###); | ||
} | ||
|
||
|