diff --git a/cli/src/commands/git.rs b/cli/src/commands/git.rs index 79252d683..b1298bdc1 100644 --- a/cli/src/commands/git.rs +++ b/cli/src/commands/git.rs @@ -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!( diff --git a/cli/tests/test_git_push.rs b/cli/tests/test_git_push.rs index 9ccafb56b..319e33f47 100644 --- a/cli/tests/test_git_push.rs +++ b/cli/tests/test_git_push.rs @@ -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.