Skip to content

Commit eb5b78a

Browse files
committed
push: respect branch.*.merge ref, if specified
1 parent 7d60d53 commit eb5b78a

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

asyncgit/src/sync/remotes/push.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use crate::{
44
sync::{
55
branch::branch_set_upstream_after_push,
66
cred::BasicAuthCredential,
7+
get_branch_upstream_merge,
78
remotes::{proxy_auto, Callbacks},
89
repository::repo,
910
CommitId, RepoPath,
@@ -163,9 +164,19 @@ pub fn push_raw(
163164
PushType::Tag => "tags",
164165
};
165166

166-
let branch_name =
167+
let mut push_ref =
167168
format!("{branch_modifier}refs/{ref_type}/{branch}");
168-
remote.push(&[branch_name.as_str()], Some(&mut options))?;
169+
170+
if !delete {
171+
if let Ok(Some(branch_upstream_merge)) =
172+
get_branch_upstream_merge(repo_path, branch)
173+
{
174+
push_ref.push_str(&format!(":{branch_upstream_merge}"));
175+
}
176+
}
177+
178+
log::debug!("push to: {push_ref}");
179+
remote.push(&[push_ref], Some(&mut options))?;
169180

170181
if let Some((reference, msg)) =
171182
callbacks.get_stats()?.push_rejected_msg

0 commit comments

Comments
 (0)