@@ -597,6 +597,7 @@ impl GitRepository for FakeGitRepository {
fn push(
&self,
_branch: String,
+ _remote_branch: String,
_remote: String,
_options: Option<PushOptions>,
_askpass: AskPassDelegate,
@@ -573,6 +573,7 @@ pub trait GitRepository: Send + Sync {
fn push(
&self,
branch_name: String,
+ remote_branch_name: String,
upstream_name: String,
options: Option<PushOptions>,
askpass: AskPassDelegate,
@@ -1886,6 +1887,7 @@ impl GitRepository for RealGitRepository {
fn push(
&self,
branch_name: String,
+ remote_branch_name: String,
remote_name: String,
options: Option<PushOptions>,
ask_pass: AskPassDelegate,
@@ -1910,7 +1912,7 @@ impl GitRepository for RealGitRepository {
PushOptions::Force => "--force-with-lease",
}))
.arg(remote_name)
- .arg(format!("{}:{}", branch_name, branch_name))
+ .arg(format!("{}:{}", branch_name, remote_branch_name))
.stdin(smol::process::Stdio::null())
.stdout(smol::process::Stdio::piped())
.stderr(smol::process::Stdio::piped());
@@ -3053,6 +3053,14 @@ impl GitPanel {
let push = repo.update(cx, |repo, cx| {
repo.push(
branch.name().to_owned().into(),
+ branch
+ .upstream
+ .as_ref()
+ .filter(|u| matches!(u.tracking, UpstreamTracking::Tracked(_)))
+ .and_then(|u| u.branch_name())
+ .unwrap_or_else(|| branch.name())
+ .to_owned()
+ .into(),
remote.name.clone(),
options,
askpass_delegate,
@@ -1869,11 +1869,19 @@ impl GitStore {
});
let branch_name = envelope.payload.branch_name.into();
+ let remote_branch_name = envelope.payload.remote_branch_name.into();
let remote_name = envelope.payload.remote_name.into();
let remote_output = repository_handle
.update(&mut cx, |repository_handle, cx| {
- repository_handle.push(branch_name, remote_name, options, askpass, cx)
+ repository_handle.push(
+ branch_name,
+ remote_branch_name,
+ remote_name,
+ options,
+ askpass,
+ cx,
+ )
})?
.await??;
Ok(proto::RemoteMessageResponse {
@@ -4738,6 +4746,7 @@ impl Repository {
pub fn push(
&mut self,
branch: SharedString,
+ remote_branch: SharedString,
remote: SharedString,
options: Option<PushOptions>,
askpass: AskPassDelegate,
@@ -4765,7 +4774,7 @@ impl Repository {
let this = cx.weak_entity();
self.send_job(
- Some(format!("git push {} {} {}", args, remote, branch).into()),
+ Some(format!("git push {} {} {}:{}", args, remote, branch, remote_branch).into()),
move |git_repo, mut cx| async move {
match git_repo {
RepositoryState::Local(LocalRepositoryState {
@@ -4776,6 +4785,7 @@ impl Repository {
let result = backend
.push(
branch.to_string(),
+ remote_branch.to_string(),
remote.to_string(),
options,
askpass,
@@ -4813,6 +4823,7 @@ impl Repository {
repository_id: id.to_proto(),
askpass_id,
branch_name: branch.to_string(),
+ remote_branch_name: remote_branch.to_string(),
remote_name: remote.to_string(),
options: options.map(|options| match options {
PushOptions::Force => proto::push::PushOptions::Force,