forked from mirrors/jj
git-push: check duplicated --change branch prior to recording branch_updates
It could be moved before set_local_branch_target() to not update the local branch, but it seemed weird that --change is silently ignored. This inconsistency will be addressed later.
This commit is contained in:
parent
f88679bb45
commit
620f0cd35f
2 changed files with 6 additions and 8 deletions
|
@ -860,9 +860,6 @@ fn cmd_git_push(
|
|||
command.settings().push_branch_prefix(),
|
||||
commit.change_id().hex()
|
||||
);
|
||||
if !seen_branches.insert(branch_name.clone()) {
|
||||
continue;
|
||||
}
|
||||
let view = tx.base_repo().view();
|
||||
if view.get_local_branch(&branch_name).is_absent() {
|
||||
// A local branch with the full change ID doesn't exist already, so use the
|
||||
|
@ -895,6 +892,9 @@ fn cmd_git_push(
|
|||
local_target: tx.repo().view().get_local_branch(&branch_name),
|
||||
remote_ref: tx.repo().view().get_remote_branch(&branch_name, &remote),
|
||||
};
|
||||
if !seen_branches.insert(branch_name.clone()) {
|
||||
continue;
|
||||
}
|
||||
match classify_branch_update(&branch_name, &remote, targets) {
|
||||
Ok(Some(update)) => branch_updates.push((branch_name.clone(), update)),
|
||||
Ok(None) => writeln!(
|
||||
|
|
|
@ -422,7 +422,7 @@ fn test_git_push_changes() {
|
|||
Force branch push-yostqsxwqrlt from 48d8c7948133 to b5f030322b1d
|
||||
"###);
|
||||
|
||||
// FIXME: specifying the same branch with --change/--branch doesn't break things
|
||||
// specifying the same branch with --change/--branch doesn't break things
|
||||
std::fs::write(workspace_root.join("file"), "modified4").unwrap();
|
||||
let (stdout, stderr) = test_env.jj_cmd_ok(
|
||||
&workspace_root,
|
||||
|
@ -432,7 +432,6 @@ fn test_git_push_changes() {
|
|||
insta::assert_snapshot!(stderr, @r###"
|
||||
Branch changes to push to origin:
|
||||
Force branch push-yostqsxwqrlt from b5f030322b1d to 4df62cec2ee4
|
||||
Force branch push-yostqsxwqrlt from b5f030322b1d to 4df62cec2ee4
|
||||
"###);
|
||||
|
||||
// FIXME: try again with --change that moves the branch forward
|
||||
|
@ -462,14 +461,13 @@ fn test_git_push_changes() {
|
|||
insta::assert_snapshot!(stderr, @r###"
|
||||
Branch changes to push to origin:
|
||||
Force branch push-yostqsxwqrlt from 4df62cec2ee4 to fa16a14170fb
|
||||
Force branch push-yostqsxwqrlt from 4df62cec2ee4 to 3e2ce808759b
|
||||
"###);
|
||||
let stdout = test_env.jj_cmd_success(&workspace_root, &["status"]);
|
||||
insta::assert_snapshot!(stdout, @r###"
|
||||
Working copy changes:
|
||||
M file
|
||||
Working copy : yostqsxw 3e2ce808 push-yostqsxwqrlt | bar
|
||||
Parent commit: yqosqzyt fa16a141 push-yqosqzytrlsw | foo
|
||||
Working copy : yostqsxw 3e2ce808 push-yostqsxwqrlt* | bar
|
||||
Parent commit: yqosqzyt fa16a141 push-yostqsxwqrlt@origin push-yqosqzytrlsw | foo
|
||||
"###);
|
||||
|
||||
// Test changing `git.push-branch-prefix`. It causes us to push again.
|
||||
|
|
Loading…
Reference in a new issue