From 9aa1eefe81acd766d2fc60bdd62f83144fa9c158 Mon Sep 17 00:00:00 2001 From: Lucas Eekhof <105216949+eekhof@users.noreply.github.com> Date: Sun, 2 Mar 2025 19:35:22 +0100 Subject: [PATCH] fix: respect pushDefault config option --- src/git/remote.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/git/remote.rs b/src/git/remote.rs index cdce6c2554..ecf92de18c 100644 --- a/src/git/remote.rs +++ b/src/git/remote.rs @@ -101,6 +101,17 @@ pub(crate) fn head_push_remote_cfg(repo: &Repository) -> Res { } else { return Err("Head is not a branch".into()); }; + let push_remote_cfg = format!("branch.{branch}.pushRemote"); - Ok(push_remote_cfg) + let config = repo.config()?; + if config.get_string(&push_remote_cfg).is_ok() { + Ok(push_remote_cfg) + } else { + let push_default_cfg = "remote.pushDefault".to_string(); + if config.get_string(&push_default_cfg).is_ok() { + Ok(push_default_cfg) + } else { + Err("Neither pushRemote nor push.default is configured".into()) + } + } }