Skip to content

Commit 5032923

Browse files
Fix remote worktree picker hides "Create from origin/main" option (#59134)
This passes the `include_remote_name` flag through the remote `GetDefaultBranch` RPC instead of dropping it at the client/host boundary. That lets remote repositories resolve default branches as `origin/main` when needed, so worktree creation uses a valid remote branch name instead of falling back to `main`. Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments - [x] The content adheres to Zed's UI standards ([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) and [icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md) guidelines) - [ ] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable Closes #59121 Release Notes: - Fixed remote worktree creation from the default branch when the default branch requires its remote name. --------- Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
1 parent c5383ce commit 5032923

4 files changed

Lines changed: 31 additions & 1 deletion

File tree

crates/collab/tests/integration/integration_tests.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7310,6 +7310,20 @@ async fn test_remote_git_branches(
73107310
});
73117311

73127312
assert_eq!(host_branch.name(), "totally-new-branch");
7313+
7314+
let default_branch_b = cx_b
7315+
.update(|cx| repo_b.update(cx, |repository, _cx| repository.default_branch(false)))
7316+
.await
7317+
.unwrap()
7318+
.unwrap();
7319+
assert_eq!(default_branch_b.as_deref(), Some("main"));
7320+
7321+
let default_branch_with_remote_b = cx_b
7322+
.update(|cx| repo_b.update(cx, |repository, _cx| repository.default_branch(true)))
7323+
.await
7324+
.unwrap()
7325+
.unwrap();
7326+
assert_eq!(default_branch_with_remote_b.as_deref(), Some("origin/main"));
73137327
}
73147328

73157329
#[gpui::test]

crates/project/src/git_store.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3540,7 +3540,7 @@ impl GitStore {
35403540

35413541
let branch = repository_handle
35423542
.update(&mut cx, |repository_handle, _| {
3543-
repository_handle.default_branch(false)
3543+
repository_handle.default_branch(envelope.payload.include_remote_name)
35443544
})
35453545
.await??
35463546
.map(Into::into);
@@ -8349,6 +8349,7 @@ impl Repository {
83498349
.request(proto::GetDefaultBranch {
83508350
project_id: project_id.0,
83518351
repository_id: id.to_proto(),
8352+
include_remote_name,
83528353
})
83538354
.await?;
83548355

crates/proto/proto/git.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,7 @@ message BlameBufferResponse {
512512
message GetDefaultBranch {
513513
uint64 project_id = 1;
514514
uint64 repository_id = 2;
515+
bool include_remote_name = 3;
515516
}
516517

517518
message GetDefaultBranchResponse {

crates/remote_server/src/remote_editing_tests.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2800,6 +2800,20 @@ async fn test_remote_git_branches(cx: &mut TestAppContext, server_cx: &mut TestA
28002800
});
28012801

28022802
assert_eq!(server_branch.name(), "totally-new-branch");
2803+
2804+
let default_branch = cx
2805+
.update(|cx| repository.update(cx, |repository, _cx| repository.default_branch(false)))
2806+
.await
2807+
.unwrap()
2808+
.unwrap();
2809+
assert_eq!(default_branch.as_deref(), Some("main"));
2810+
2811+
let default_branch_with_remote = cx
2812+
.update(|cx| repository.update(cx, |repository, _cx| repository.default_branch(true)))
2813+
.await
2814+
.unwrap()
2815+
.unwrap();
2816+
assert_eq!(default_branch_with_remote.as_deref(), Some("origin/main"));
28032817
}
28042818

28052819
#[gpui::test]

0 commit comments

Comments
 (0)